DoCmd.OpenForm problems

skippypower

Registered User.
Local time
Today, 14:44
Joined
Jan 6, 2012
Messages
10
Hi Everyone,
Kinda new to VBA and been lurking on here and learnt a lot already.

OK ... i have 2 forms:

TestForm1
TestForm2

In TestForm1 i have a text box called TextBox1 and Button called Button1. im trying to open TestForm2 when u click Button1 and go to the record in TextBox1. The priamary record in TestForm2 is ID.

All i seem to be getting is enter parameter value box!!! what am i doing wrong?? i have tryed a number of diffrent things; brackets in diffrent places, me.TextBox1, commers in diffrent places.... nothing seems to be working. Nightmare!

Private Sub Button1_Click()

DoCmd.OpenForm "TestForm2", , , "ID = TextBox1"

End Sub
 
Welcome to the Forum,

Try something along these lines.

Create a Macro (in the macro section of your database) to open form2 and add the condition in the macro at the bottom to use the OpenForm1.ID = to the Table where the source comes from ID field.

Then Open the Form1 in design view and drag the macro onto your form1 and then save and change the view to test it, if it works ok (which it should do based on your thread) then you can convert the macro button on the form in VBA.

I have just replicated this, and the DoCmd code is shown below

DoCmd.OpenForm "frmEmployeeLink", acNormal, "", "[Forms]![frmEmployeeMain]![id]=[tblEmployee]![id]", , acNormal
 
Yeah that seems to do the trick.
Thanks!!
 
Happy to Help.

Thanks for letting me know it works for you. :)
 

Users who are viewing this thread

Back
Top Bottom