whats wrong with this statement

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

Guest

strwhere = strwhere & "#[queryname.fieldname]# Between " & "#" & Me.BegDate &
"#" & " And " & "#" & Me.EndDate & "#"

I'm trying to read a date field in a query from a combo box statement....
 
The # delimiter is needed around the date values, not around the field name.
Also, if you use the square brackets, they must go around the query name and
field name separately.

Add this line after yours:
Debug.Print strWhere

Then when it runs, open the Immediate Window (press Ctrl+G) and see what
came out. Your goal is to create a string like this:
[Query1].[Field1] Between #1/1/2005# And #1/1/2006#
 
accessdesigner said:
strwhere = strwhere & "#[queryname.fieldname]# Between " & "#" &
Me.BegDate &
"#" & " And " & "#" & Me.EndDate & "#"

I'm trying to read a date field in a query from a combo box statement....

What error are you getting? Could it be that you need a space character
before the first hash?

Keith.
www.keithwilby.com
 
could u give me an example of one that would work, using a field from a
query, and a criteria between combodate1 and combodate2?

Allen Browne said:
The # delimiter is needed around the date values, not around the field name.
Also, if you use the square brackets, they must go around the query name and
field name separately.

Add this line after yours:
Debug.Print strWhere

Then when it runs, open the Immediate Window (press Ctrl+G) and see what
came out. Your goal is to create a string like this:
[Query1].[Field1] Between #1/1/2005# And #1/1/2006#

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

accessdesigner said:
strwhere = strwhere & "#[queryname.fieldname]# Between " & "#" &
Me.BegDate &
"#" & " And " & "#" & Me.EndDate & "#"

I'm trying to read a date field in a query from a combo box statement....
 
it wont recognize my statement at all, and locks the query from being opened
at all

Keith Wilby said:
accessdesigner said:
strwhere = strwhere & "#[queryname.fieldname]# Between " & "#" &
Me.BegDate &
"#" & " And " & "#" & Me.EndDate & "#"

I'm trying to read a date field in a query from a combo box statement....

What error are you getting? Could it be that you need a space character
before the first hash?

Keith.
www.keithwilby.com
 
It's not clear where you are using this.

Are you building up a Filter for a form, or WhereCondition for OpenReport?
Is the form/report based on a query, so you are trying to match *that* query
field?

There's an example using text boxes here:
Limiting a Report to a Date Range
at:
http://allenbrowne.com/casu-08.html
The process is identical for combo boxes.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

accessdesigner said:
could u give me an example of one that would work, using a field from a
query, and a criteria between combodate1 and combodate2?

Allen Browne said:
The # delimiter is needed around the date values, not around the field
name.
Also, if you use the square brackets, they must go around the query name
and
field name separately.

Add this line after yours:
Debug.Print strWhere

Then when it runs, open the Immediate Window (press Ctrl+G) and see what
came out. Your goal is to create a string like this:
[Query1].[Field1] Between #1/1/2005# And #1/1/2006#

message
strwhere = strwhere & "#[queryname.fieldname]# Between " & "#" &
Me.BegDate &
"#" & " And " & "#" & Me.EndDate & "#"

I'm trying to read a date field in a query from a combo box
statement....
 
Thats ok, i got it:
strwhere = strwhere & "[queryname.fieldname]Between #" & Me.BegDate & "#" &
" And " & "#" & Me.EndDate & "#"

accessdesigner said:
it wont recognize my statement at all, and locks the query from being opened
at all

Keith Wilby said:
accessdesigner said:
strwhere = strwhere & "#[queryname.fieldname]# Between " & "#" &
Me.BegDate &
"#" & " And " & "#" & Me.EndDate & "#"

I'm trying to read a date field in a query from a combo box statement....

What error are you getting? Could it be that you need a space character
before the first hash?

Keith.
www.keithwilby.com
 
accessdesigner said:
Thats ok, i got it:
strwhere = strwhere & "[queryname.fieldname]Between #" & Me.BegDate & "#"
&
" And " & "#" & Me.EndDate & "#"

I read your OP *way* too fast! How about:

strwhere = strwhere & "[queryname].[fieldname] Between #" & Me.BegDate & "#
And #" & Me.EndDate & "#"

Depending on your location in the world, you might have to use the Format
function around the dates too.

Regards,
Keith.
 
yes, thats works.... one last question.... how do create a combo box to allow
the user to type in keywords that is connected to a memo field within a
query? could u show me an example of one that works... using the strwhere
statement, but how is the combo setup, and its property fields?

Keith Wilby said:
accessdesigner said:
Thats ok, i got it:
strwhere = strwhere & "[queryname.fieldname]Between #" & Me.BegDate & "#"
&
" And " & "#" & Me.EndDate & "#"

I read your OP *way* too fast! How about:

strwhere = strwhere & "[queryname].[fieldname] Between #" & Me.BegDate & "#
And #" & Me.EndDate & "#"

Depending on your location in the world, you might have to use the Format
function around the dates too.

Regards,
Keith.
 
Back
Top