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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Load command Access 2000 vba

Status
Not open for further replies.

pd84313

Programmer
Aug 26, 2002
11
AU
Hello - whats with the load statement in Access ?

This is the help code

Private Sub UserForm_Initialize()
Load UserForm2
UserForm2.Show
End Sub

But what is a Userform ?

The help says

UserForm is an Object data type. You can declare variables as type UserForm before setting them to an instance of a type of UserForm declared at design time. Similarly, you can pass an argument to a procedure as type UserForm. You can create multiple instances of user forms in code by using the New keyword in Dim, Set, and Static statements.

Tried to dim and set a variable to be a Userform object but no luck

Can I do this or what ? I can't seem to reference a form unless it is part of the forms collection - why can't this be as easy as it is in vb ?????????????????????

ps I want to load the form to do some stuff to it before I show it so the docmd openform FormName isn't an option

Thankyou oh more knowlegeable in access one
 
Hi

You could
use DoCmd to open the form,
set the visible property to false,
do what ever it is you want to do,
then set the visible property to true,

Regards

Ken Reay
Freelance Developer
kenneth.reay@talk21.com
 
Hey thanks Ken but I think that I found the answer on the MS web site - but your solution is now the only way to go : )


ACC2000: Access 2000 Does Not Support the UserForm Object
The information in this article applies to:
Microsoft Access 2000
Microsoft Visual Basic for Applications

Moderate: Requires basic macro, coding, and interoperability skills.

This article applies to a Microsoft Access database (.mdb) and a Microsoft Access project (.adp).


Summary
In Help in the Visual Basic Editor, you see methods, properties, events, and statements that apply only to the UserForm object. However, even though it is possible to create and to use UserForms in the Visual Basic Editor, it is recommended that you not use them with Access. Instead, use Access forms.
More Information
You receive the following error message if you try to use a UserForm method, property, or statement on an object other than the UserForm (for example, a Microsoft Access form) in Visual Basic for Applications code:

Run-time error '2465':


Application-defined or object-defined error
Using the following methods, properties, or statements on objects other than UserForms will cause the error:
Methods
-------
Hide
PrintForm
Show
WhatsThisMode

Properties
----------
StartUpPosition
WhatsThisButton
WhatsTHisHelp

Statements
----------
Load
Unload
NOTE: The Load statement and the Unload statement of UserForms are not to be confused with the Load event and the Unload event of Microsoft Access forms. The syntax contained in the Help topics for the Load and Unload statements do not work with Access forms.
References
For more information about the UserForm object, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type "UserForm object" in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top