Select a parameter for my query

  • Thread starter Thread starter LMB
  • Start date Start date
L

LMB

Hi Guys,

Access 2000. I have a parameter query that I made. I have a field "Name"
which is a concatenated field from a sub query. I put [Type last name,
first name] in the criteria field. This gives me the results I want which
is to only see one record instead of all the records. The problem is that I
have to type the last name and first name exactly right with the comma and
space for it to work. Is there a way to create a dropdown list of the names
so the user can select the name instead of typing it in?

Thanks,
Linda
 
Create a form that has a combobox on it that displays all of the names.

In your query, replace [Type last name, first name] in the criteria field
with Forms![MyForm]![MyCombo] (Use your actual names rather than MyForm and
MyCombo)

Note, however, that this will only work if the form is open when you run the
query. If it isn't, you'll get the same prompt you're used to, except it
won't have the helpful "Type last name, first name" instruction on it.
 
Thanks, Doug. I'll try later when I have more time because apparently my
combo box building skills are lacking at this point. When I do get it
working properly, how should I name this form? I have never made a form
other than a sbfrm or frm (main form) I am thinking I should name the combo
box cboEmployeeNames or do you have a different idea about that?

Thanks,
Linda


Douglas J. Steele said:
Create a form that has a combobox on it that displays all of the names.

In your query, replace [Type last name, first name] in the criteria field
with Forms![MyForm]![MyCombo] (Use your actual names rather than MyForm
and MyCombo)

Note, however, that this will only work if the form is open when you run
the query. If it isn't, you'll get the same prompt you're used to, except
it won't have the helpful "Type last name, first name" instruction on it.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



LMB said:
Hi Guys,

Access 2000. I have a parameter query that I made. I have a field
"Name" which is a concatenated field from a sub query. I put [Type last
name, first name] in the criteria field. This gives me the results I
want which is to only see one record instead of all the records. The
problem is that I have to type the last name and first name exactly right
with the comma and space for it to work. Is there a way to create a
dropdown list of the names so the user can select the name instead of
typing it in?

Thanks,
Linda
 
cboEmployeeNames sounds fine for the combo box name. The form can be named
anything you want. If it helps, you could refer to the query to which it's
related: frmLookupForqryXXX

If you want to get sophisticated, you could put code into the combo box's
AfterUpdate event to have it open the query. In that way, you'd always have
the form open when you ran the query.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



LMB said:
Thanks, Doug. I'll try later when I have more time because apparently my
combo box building skills are lacking at this point. When I do get it
working properly, how should I name this form? I have never made a form
other than a sbfrm or frm (main form) I am thinking I should name the
combo box cboEmployeeNames or do you have a different idea about that?

Thanks,
Linda


Douglas J. Steele said:
Create a form that has a combobox on it that displays all of the names.

In your query, replace [Type last name, first name] in the criteria field
with Forms![MyForm]![MyCombo] (Use your actual names rather than MyForm
and MyCombo)

Note, however, that this will only work if the form is open when you run
the query. If it isn't, you'll get the same prompt you're used to, except
it won't have the helpful "Type last name, first name" instruction on it.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



LMB said:
Hi Guys,

Access 2000. I have a parameter query that I made. I have a field
"Name" which is a concatenated field from a sub query. I put [Type last
name, first name] in the criteria field. This gives me the results I
want which is to only see one record instead of all the records. The
problem is that I have to type the last name and first name exactly
right with the comma and space for it to work. Is there a way to create
a dropdown list of the names so the user can select the name instead of
typing it in?

Thanks,
Linda
 
I had a similar need and generally was able to use this information to get
going, but I was trying to use the value from a DtPicker object (inserted
from the "More Controls" selection from the toolbar). The date pickers don't
show up from the builder when I try to add the criteria to the query and if I
hand type in the name of the object on the form, I get an error when the
report is run. Is it just that the ActiveX controls can't be used to supply
query parameters or is there some other trick?

Douglas J. Steele said:
Create a form that has a combobox on it that displays all of the names.

In your query, replace [Type last name, first name] in the criteria field
with Forms![MyForm]![MyCombo] (Use your actual names rather than MyForm and
MyCombo)

Note, however, that this will only work if the form is open when you run the
query. If it isn't, you'll get the same prompt you're used to, except it
won't have the helpful "Type last name, first name" instruction on it.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



LMB said:
Hi Guys,

Access 2000. I have a parameter query that I made. I have a field "Name"
which is a concatenated field from a sub query. I put [Type last name,
first name] in the criteria field. This gives me the results I want which
is to only see one record instead of all the records. The problem is that
I have to type the last name and first name exactly right with the comma
and space for it to work. Is there a way to create a dropdown list of the
names so the user can select the name instead of typing it in?

Thanks,
Linda
 
Back
Top