Docmd Set Filter

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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
 
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
 
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
 
Back
Top