Docmd Set Filter

W

williamr

I have a query that has a field called "vaultNo" and a variable from a form
called lngreleasenumber. I'm trying to set the filter to the vaultno that
equals the variable I supply. I call myself following the example in the
"ApplyFilter" help with no luck.

DoCmd.OpenQuery ("qryBill")
DoCmd.ApplyFilter , "[vaultNo] , = lngreleasenumber"

Thank You
Mr. Dumb
 
K

Klatuu

You can't assign a memory variable as a parameter for a query. You need to
turn it into a string:

If valutNo is a text field:
DoCmd.ApplyFilter , "[vaultNo] = '" & lngreleasenumber & "'"
If it is a numeric field
DoCmd.ApplyFilter , "[vaultNo] = " & lngreleasenumber
 
W

williamr

Thank You

Klatuu said:
You can't assign a memory variable as a parameter for a query. You need to
turn it into a string:

If valutNo is a text field:
DoCmd.ApplyFilter , "[vaultNo] = '" & lngreleasenumber & "'"
If it is a numeric field
DoCmd.ApplyFilter , "[vaultNo] = " & lngreleasenumber


williamr said:
I have a query that has a field called "vaultNo" and a variable from a form
called lngreleasenumber. I'm trying to set the filter to the vaultno that
equals the variable I supply. I call myself following the example in the
"ApplyFilter" help with no luck.

DoCmd.OpenQuery ("qryBill")
DoCmd.ApplyFilter , "[vaultNo] , = lngreleasenumber"

Thank You
Mr. Dumb
 
W

williamr

Klatuu, Hi. I entered it but it opens the query then ask for the vault like
it would if I put [..] in the criteria of the query

williamr said:
Thank You

Klatuu said:
You can't assign a memory variable as a parameter for a query. You need to
turn it into a string:

If valutNo is a text field:
DoCmd.ApplyFilter , "[vaultNo] = '" & lngreleasenumber & "'"
If it is a numeric field
DoCmd.ApplyFilter , "[vaultNo] = " & lngreleasenumber


williamr said:
I have a query that has a field called "vaultNo" and a variable from a form
called lngreleasenumber. I'm trying to set the filter to the vaultno that
equals the variable I supply. I call myself following the example in the
"ApplyFilter" help with no luck.

DoCmd.OpenQuery ("qryBill")
DoCmd.ApplyFilter , "[vaultNo] , = lngreleasenumber"

Thank You
Mr. Dumb
 
D

Douglas J. Steele

That implies that what you typed in the field isn't the actual name of the
field in the query.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


williamr said:
Klatuu, Hi. I entered it but it opens the query then ask for the vault
like
it would if I put [..] in the criteria of the query

williamr said:
Thank You

Klatuu said:
You can't assign a memory variable as a parameter for a query. You
need to
turn it into a string:

If valutNo is a text field:
DoCmd.ApplyFilter , "[vaultNo] = '" & lngreleasenumber & "'"
If it is a numeric field
DoCmd.ApplyFilter , "[vaultNo] = " & lngreleasenumber


:

I have a query that has a field called "vaultNo" and a variable from
a form
called lngreleasenumber. I'm trying to set the filter to the vaultno
that
equals the variable I supply. I call myself following the example in
the
"ApplyFilter" help with no luck.

DoCmd.OpenQuery ("qryBill")
DoCmd.ApplyFilter , "[vaultNo] , = lngreleasenumber"

Thank You
Mr. Dumb
 

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