Entering criteria from form

L

LY

I'm fairly new to Access and largely unfamiliar with coding, so keep that in
mind when replying please. =)


I have a query with several different fields that pulls the criteria from
textboxes in an unbound form.

The code I am using in the fields "criteria":

Like IIf(IsNull([Forms]![Info].[Proposal ID]),"*",[Forms]![Info].[Proposal
ID])
(form's name = info, example textbox name = Proposal ID)

The problem is that I have many text boxes (and thus, fields in my query)
but I only want a couple to show up when I run the query. However, when I
uncheck the "show" option on a field an "Enter Parameter Value" pop-up opens
up when the query is run

How can I make it so that the user has the ability to specify criteria for a
field but not have that field show up when the query is run?

Thanks!
 
S

S.Clark

Create a form to capture the criteria. Use textboxes, comboboxes, etc to
gather the criteria.

Add a button also. In the code behind the button, create a dynamic string to
make a where clause string.

Suppose there is a textbox called txtValue.
On the form, the user enters a value in txtValue.

in the code, you code have:

dim strW as string

If Len(txtValue & "") > 0 then
strW = "[MyField] = '" & txtValue "'"
end if

I don't know what you do with the query data when it runs, but once you have
it in a string, you can do a lot of things with it.
 
L

LY

When I paste the code it says "Compile error: Expected end of statement"
and, I have about 40 or so textboxes that the user is entering in information
in to. Would I have to do this for each one? Isn't there a simpler way to
do this, like a a different code I could enter in to the Criteria area of the
fields in the query to pull the information from the form?
S.Clark said:
Create a form to capture the criteria. Use textboxes, comboboxes, etc to
gather the criteria.

Add a button also. In the code behind the button, create a dynamic string to
make a where clause string.

Suppose there is a textbox called txtValue.
On the form, the user enters a value in txtValue.

in the code, you code have:

dim strW as string

If Len(txtValue & "") > 0 then
strW = "[MyField] = '" & txtValue "'"
end if

I don't know what you do with the query data when it runs, but once you have
it in a string, you can do a lot of things with it.

LY said:
I'm fairly new to Access and largely unfamiliar with coding, so keep that in
mind when replying please. =)


I have a query with several different fields that pulls the criteria from
textboxes in an unbound form.

The code I am using in the fields "criteria":

Like IIf(IsNull([Forms]![Info].[Proposal ID]),"*",[Forms]![Info].[Proposal
ID])
(form's name = info, example textbox name = Proposal ID)

The problem is that I have many text boxes (and thus, fields in my query)
but I only want a couple to show up when I run the query. However, when I
uncheck the "show" option on a field an "Enter Parameter Value" pop-up opens
up when the query is run

How can I make it so that the user has the ability to specify criteria for a
field but not have that field show up when the query is run?

Thanks!
 

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

Similar Threads


Top