Using current form's record, open another form on click

karmacable

Registered User.
Local time
Today, 06:04
Joined
Sep 13, 2011
Messages
32
Jeez, I've gotten so spoiled using the macros for simply opening a form, I'm now having problems simply writing it into VBA (Access's "convert macro to VBA" button doesn't work very well)?!

Okay, this should be really simple but my syntax for SQL and opening code isn't tops. Here's the info;

My current form: frmProject -> uses tblProject -> ProjectID (PK-Number)

Form to open: frmReport -> source also uses tblProject
currently has only two textboxes copied from frmProject -> txtProjectID & txtProject (for the project name)
While a user is cruising along from record to record in frmProject, let's say he/she stops at record 13 for the project called "BillyBob" (record 12 for BobbySue and record 14 for Cletus just weren't as interesting)!

Anyways, the user simply wants to click on command button and have frmReport come up with some of the information already shown for Billybob on frmProject, AND have some extra info show up (which will come from some coding I wish to do in the 'click' event for the command button, again don't worry about that).

So to my logical thinking, the syntax for this procedure looks like this;

DoCmd.OpenForm "frmReport", , , "txtProject=" & Me!ProjectID
But I'm getting a 'Enter Parameter Value' prompt for txtProject. I just want the record for BillyBob to show, I do not want the user to be prompted!

Anyways, feel free to illustrate where my idiot logic is going wrong.

Thanks,
 
Again, sorry for my idiocy, but txtProject should be bound to what?

Feel free to correct the Syntax of my current statement.
 
What I meant was, you should replace txtProject with the name of the field. Don't use the control name. I can only guess that the field name is ProjectID, so your code should read:
Code:
DoCmd.OpenForm "frmReport", , , "ProjectID=" & Me!ProjectID

This link should help:

http://baldyweb.com/wherecondition.htm
 
Thanks, my stupidity is now fading...for the time being...
 

Users who are viewing this thread

Back
Top Bottom