Custom Parameter Query - Help, please?

Joined
Jun 12, 2011
Messages
2
Reaction score
0
Hello,
I'm pretty novice so I hope you'll see something quick and easy and not laugh at my attempts. :blush:

I'm creating a Switchboard/Navigation Page (not sure if I plan to use the MS Switchboard or not...it wasn't an option last time I needed to fiddle w/Access). Anyway, I feel like I'm 90% of the way there, but keep failing.

I have a form (currently named: ztestNavButton) dressed up like a parameter query input box. It contains one text box (unbound; named: txtInputPN1) and one button (default name: Command4). The user is intended to enter the Project Number in the text box, press the button and it will open a form to the record specified by the Project Number so that new records can be entered into the associated subform.

Here's the associated code:

Private Sub Command4_Click()
DoCmd.OpenForm "frmProjectSites", , , "ProjNumber = Me.txtInputPN1"
DoCmd.Close acForm, "ztestNavButton"
End Sub


The button SORT OF works....but when I press it, it brings up a NEW dialog called "Enter Parameter Value" with identifier Me.txtInputPN1. If I enter the same Project Number there as I did in the text box, my form opens to the record I intended and life is good. But I just can't figure out what is wrong with my original "Me.txtInputPN1" argument such that Access doesn't recognize it. It seems that the rest of the code does what I want...

I hope this is obvious to someone else, as I'm on a tight deadline and getting deeper and deeper into the weeds with this thing! Thanks to anyone with suggestions!!!
 
Joined
Jun 12, 2011
Messages
2
Reaction score
0
Okay, I got a little sleep and then came back to this. Finally found some online info that made a difference. Functional code:

Private Sub Command4_Click()
DoCmd.OpenForm "frmProjectSites", , , "[ProjNumber]='" & Me.txtInputPN1 & "'"
DoCmd.Close acForm, "ztestNavButton"
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top