combo box search

S

Stu

Good Morning! Quick Question for you
I have two forms, Form A and Form B. Form B has many
records, all with different Project_Names. I have a combo
box on Form A linked to all the Project_Names. When the
user selects a Project_Name and hits the command button
Find, I want to open Form B and go to that record with the
Project_Name.
So far it is only opening Form B, not going to the desired
project,
Thanks for your help
 
S

Sandra Daigle

Hi Stu,

Try using the WhereCondition parameter of docmd.openform. For example:

docmd.openform "frmB",,,"ProjectName=""" & me.ProjectName & """"

Don't remove the extra quotes from the above if ProjectName is actually a
text field. If you are really linking on a numeric primary key field you can
do it like this:

docmd.openform "frmB",,,"Projectid=" & me.Projectid
 
S

Stu

Thank you for your reply Sandra.
When I wrote that code, Enter Paramater Value msg box came
up for ProjectName. I tried to change everything around,
but I could not figure out why it was asking me for
ProjectName.
So let me show you what I have. Form A has a combo
box "cmbProjectName" linked to any Project names entered
on Form B in text box "ProjectName"
This is the code I have:
DoCmd.OpenForm "frminputpage", , , "ProjectName=""" &
Me.cmbProjectName & """"
I have never used this parameter but it looks as if its
not understanding the ProjectName on Form B.
Any additional help would be great, thanks
-----Original Message-----
Hi Stu,

Try using the WhereCondition parameter of docmd.openform. For example:

docmd.openform "frmB",,,"ProjectName=""" & me.ProjectName & """"

Don't remove the extra quotes from the above if ProjectName is actually a
text field. If you are really linking on a numeric primary key field you can
do it like this:

docmd.openform "frmB",,,"Projectid=" & me.Projectid


--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.
Good Morning! Quick Question for you
I have two forms, Form A and Form B. Form B has many
records, all with different Project_Names. I have a combo
box on Form A linked to all the Project_Names. When the
user selects a Project_Name and hits the command button
Find, I want to open Form B and go to that record with the
Project_Name.
So far it is only opening Form B, not going to the desired
project,
Thanks for your help

.
 
S

Sandra Daigle

In frmB is there actually a field in the Recordsource query which is named
ProjectName? If not, then change it to the actual field name. Note that if
your field name is 'Project Name' you have to code it like this: '[Project
Name] ' so the command would become:

docmd.openform "frmB",,,"[Project Name]=""" & me.ProjectName & """"


--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

Thank you for your reply Sandra.
When I wrote that code, Enter Paramater Value msg box came
up for ProjectName. I tried to change everything around,
but I could not figure out why it was asking me for
ProjectName.
So let me show you what I have. Form A has a combo
box "cmbProjectName" linked to any Project names entered
on Form B in text box "ProjectName"
This is the code I have:
DoCmd.OpenForm "frminputpage", , , "ProjectName=""" &
Me.cmbProjectName & """"
I have never used this parameter but it looks as if its
not understanding the ProjectName on Form B.
Any additional help would be great, thanks
-----Original Message-----
Hi Stu,

Try using the WhereCondition parameter of docmd.openform. For
example:

docmd.openform "frmB",,,"ProjectName=""" & me.ProjectName & """"

Don't remove the extra quotes from the above if ProjectName is
actually a text field. If you are really linking on a numeric
primary key field you can do it like this:

docmd.openform "frmB",,,"Projectid=" & me.Projectid


--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.
Good Morning! Quick Question for you
I have two forms, Form A and Form B. Form B has many
records, all with different Project_Names. I have a combo
box on Form A linked to all the Project_Names. When the
user selects a Project_Name and hits the command button
Find, I want to open Form B and go to that record with the
Project_Name.
So far it is only opening Form B, not going to the desired
project,
Thanks for your help

.
 
S

Stu

Thanks you very much for your help. I just figured it
out, so you can disregard that last email. Thanks again -
Stu
 

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