Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have a problem with dates in a form filter using "between" 1

Status
Not open for further replies.

adita1983

Technical User
Dec 28, 2004
7
RO
Hello,

Can u help me please with the following problem?
A want to use "between" in a filter with 2 dates.Here is the code:

Private Sub Submit_Click()

Dim str As String
str = "Total_sampling.Statusenddate between #"&Me.Data1&"# AND #"&Me.Data2&"#"

DoCmd.OpenForm "Total_sampling", acFormDS, , str

End Sub


I recive the error Expected: end of statement

Tks a lot,
Adrian
 
adita1983 . . . . .

Try:
Code:
[blue]str = "[Statusenddate] between #" & Me.Data1 & "# AND #" & Me.Data2 & "#"[/blue]


Calvin.gif
See Ya! . . . . . .
 
Hi

"Having a problem" does not tell us much about what is actually happening, do you get a syntax error, do you get "wrong" data returned, Error message(s)?

Dates must be presented in a limited number of formats try

Private Sub Submit_Click()

Dim str As String
str = "Total_sampling.Statusenddate between #"& Format(Me.Data1,"yyyy/mm/dd") & "# AND #" & Format(Me.Data2,"yyyy/mm/dd") & "#"

DoCmd.OpenForm "Total_sampling", acFormDS, , str

End Sub




Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Hello,

It works with Format.Tks a lot Ken Reay.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top