Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open a Form from a another Form

Status
Not open for further replies.

PALman

Technical User
May 15, 2002
160
GB
Can anyone please give coding to allow me to click on a ControlButton in MainMenu.frm and have it open my second form named EnquiryDesk.frm.
This was easy in VBA but I get all sorts of errors in VB6.
I now understand I cannot use doCmd.OpenForm from Access.
One error I get frequently is "Object Required" when obviously the EnquiryDesk.frm does exist. Could there be a path problem?
 
Try:
Code:
EnquiryDesk.frm.Show

Though VB allows it, I don't use periods in names of objects or other variables because that notation is used to access properties and methods of objects. Using periods in a name makes it appear that you're referring to a property or method, and can be confusing to someone else reading your code, or even to yourself 6 months after you've put the code away.

For form objects, I use the standard prefaces - frmFormName, txtTextBoxName, lblLabelName, etc.

Lee
 
I assume EnquiryDesk.frm is a file name for a Form named EnquiryDesk

File name and Form's name do not have to be tha same, but it makes life a lot easier if they are.

If that's the case, your code will be
Code:
EnquiryDesk.Show

Other than that, I fully agree with trollacious

HTH

---- Andy
 
Thanks guys for quick reply.
I tried both and the .Show part gives error... "Method or data member not found". Do I have to create a reference to another library?
 
Copy and paste your code in here so we can see what we're working with.

Lee
 
You have mentioned EnquiryDesk.frm - but that looks to me like a file name of the Form. What is your Form's name? Click on your Form and look at the Property - it is the very first informatin about the Form. I wouldn't be surprized if it is Form3 or something like that - if you did not modified it.

If you have just one, default Form (Form1) in your VB6 app, after typing "Form1." you should see:
Code:
Form1._________________
      |ActiveControl  |
      |Appearance     |
      |AutoRedraw     |
      |BackColor      |
      ...
      |Show           |
      -----------------

HTH

---- Andy
 
EnquiryDesk.frm ?

It is not allowed to name an (accessible) object including dots. The dot in vb is a 'special' character, in order to reference a method of an object.

The one that i can think is that 'EnquiryDesk' is a class (dll ?) that contains a form object 'frm'. If it is this:

dim tmp as form
tmp = new EnquiryDesk.frm
tmp.show

Of cource , you need to add a referense to that project ro dll.

Hope this helps !
 
I believe you are trying to reuse VBA code from Access.

Much of your code that deals with UI elements (forms, controls, etc.) will not work in VB6. The VBA controls are not the same as the VB6 controls. For example, the dropdown control in Access VBA (which supports multiple columns) is not the same as the dropdown control in VB6 (which does not support multiple columns).

The DoCmd object from Access VBA does not exist in VB6. Wherever that is in your code, you will need to change to the equivalent VB6 command.
 
Thank You All.
I think a major rethink is probably my best option.
I am trying to convert all my own work in VB Access to create a Quality Control Program to help the company I work for.
However I wish to convert it to VB6 for further development/improvement. I did not realise VBA and VB6 were so different.
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top