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

Command Button to Open Form Problem!

Status
Not open for further replies.

esu4edp

Technical User
Feb 15, 2000
59
US
I know this is probably easy to answer, but I've having a problem with this code. I have a command button. I want it to open a form called Cruiser. What am I doing wrong???

Private Sub Command1_Click()
On Error GoTo Err_Command1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Cruiser"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command1_Click:
Exit Sub

Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command1_Click

End Sub
 
Change OPENFORM to SHOW, before you show the form, I usually load it first into the memory.

yourform.Load
yourform.show vbModal

[vbmodal] is an optional parameter if you want to your form to be modal.
 
For some reason it keeps telling me that the vaiable is not defined!
 
is this visual basic or VBA??

If somethings hard to do, its not worth doing - Homer Simpson
------------------------------------------------------------------------
A General Guide To Excel in VB FAQ222-3383
File Formats Galore @
 
hmmmm, its just im sure docmd is an office thing (i never seen it used in VB)

you will get "run time error 424" if you havent included a reference to the docmd object (which im not even sure is possible)

if all you want to do is show a form on the click of the button then do as vizion says and use something like

Private Sub Command1_Click()

Cruiser.Load
Cruiser.Show vbModal

End Sub

include the error routine if you think it is necessary and i dont know what stLinkCriteria is so i cant comment on that!

good luck!

If somethings hard to do, its not worth doing - Homer Simpson
------------------------------------------------------------------------
A General Guide To Excel in VB FAQ222-3383
File Formats Galore @
 

Hi ADoozer:

You are quite correct in questioning DoCmd. It is not a VB function, method, statement, . . . Th MSDN library lists it as a Visual FoxPro command.

Cassie
 
DoCmd is also valid in Visio


________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Hey thanks everyone, I got it to work but for some reason it takes awhile to open the form.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top