DoCmd OpenForm with date where condition (1 Viewer)

Wysy

Registered User.
Local time
Today, 08:44
Joined
Jul 5, 2015
Messages
333
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
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 08:44
Joined
Aug 30, 2003
Messages
36,137
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?
 

Wysy

Registered User.
Local time
Today, 08:44
Joined
Jul 5, 2015
Messages
333
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.
 

Wysy

Registered User.
Local time
Today, 08:44
Joined
Jul 5, 2015
Messages
333
Thank you! Everything worked and understood.
A
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 08:44
Joined
Aug 30, 2003
Messages
36,137
Happy to help!
 

Users who are viewing this thread

Top Bottom