DoCmd OpenForm with date where condition

Wysy

Registered User.
Local time
Today, 13:24
Joined
Jul 5, 2015
Messages
335
Hi,
I have a form DOV field with short date format. I have another form VisitFR with DOV field with short format too.
The first form has a vba code for clicking DOV field
Docmd.Openform "VisitFR",acFormDS,,"DOV=#"&Me.DOV&"#".
After clicking i have an error:Syntax error in number...
I have already tried a lot of format without success. Even changed the name of the fields so not to have the same ones.
Any idea?
Thanks
Andrew
 
Looks okay, as long as there are actually spaces in there, like:

Docmd.Openform "VisitFR",acFormDS,,"DOV= #" & Me.DOV & "#"

If that doesn't work, is there a date value in that control? The data type of the field is date/time?
 
Thanks for the fast reply. I have tried a couple of things in the meantime.
I found out that the date format must be in yyyy/mm/dd then the code works.
However i have tried to use format function in the code like
DoCmd.OpenForm "VisitFR", acFormDS, , "DOV=#" & Format(Me.DOV.Value, "yyyy/mm/dd") & "#"
But it still does not work.
 
Thank you! Everything worked and understood.
A
 

Users who are viewing this thread

Back
Top Bottom