Question 2: is it good programming practice to have more than one project in an application?
- Yes. It is good programming practice to have more than one project in an application, so to speak. You do this all the time when you use ADODB in your project, for example. Without getting into the details, a well designed application can use dozens of DLLs that provide the services that application needs. Almost any sizeable app will do so, and countless articles have been written on the how and why of this.
Question 1: How can I access forms in Project 2 from Project1?
- Assuming project 2 is an activex dll, you could create a class (let's call it MyClass) that has its instancing property set to MultiUse. This class will have a public method on it that would look something like this:
Code:
Public Sub ShowMyForm()
Dim f As MyForm
Set f = New MyForm
f.Show vbModal
End Sub
You would use code like this in project 1 in some sub or button click handler and you have a reference to Project 2 in Project 1):
Code:
Private Sub Command1_Click()
Dim o As Project2.MyClass
Set o = New Project2.MyClass
o.ShowMyForm
End Sub
Or you could make this a function like this:
Code:
Public Function GetMyForm() As Object
Set GetMyForm = New MyForm
End Function
And use it like this:
Code:
Private Sub Command2_Click()
Dim o As Project2.MyClass
Set o = New Project2.MyClass
Dim f As Form
Set f = o.GetMyForm
f.Show vbModal
End Sub
These are just simplistic examples. You will have to work with this a bit to make it do whatever it is you actually need.
Woody Z
http://www.learntoprogramnow.com