Open form criteria (1 Viewer)

dan-cat

Registered User.
Local time
Today, 16:34
Joined
Jun 2, 2002
Messages
3,433
It's a sunny day outside but I'm stuck in here struggling with a relatively simple piece of code:

Dim Kount As Integer
Dim DKount As Date
Kount = Forms!Main!DateCount
DKount = DateAdd("d", Kount, Now() - 1)
MsgBox DKount
DoCmd.OpenForm "frmDenBookingDay", , , "DenId=Forms!Main!DenId And Date Between Now() And DKount"

All I want to do is open the form with the given date criteria.
I have managed to open a msgbox displaying the correct date, however when attempting to pass that date in the criteria of the open form command it doesn't see it.

Can anyone help?

ThankYou
 

Tim K.

Registered User.
Local time
Today, 16:34
Joined
Aug 1, 2002
Messages
242
Try this.

DoCmd.OpenForm "frmDenBookingDay", , , "DenId=" & Forms!Main!DenId & " And Date Between " & Now() & " And " & DKount
 

dan-cat

Registered User.
Local time
Today, 16:34
Joined
Jun 2, 2002
Messages
3,433
Sorry Tim, I'm getting a syntax error, missing operator message on that code
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 11:34
Joined
Feb 19, 2002
Messages
43,225
DoCmd.OpenForm "frmDenBookingDay", , , "DenId=" & Forms!Main!DenId & " And Date Between #" & Date() & "# And #" & DKount & "#"
 

Users who are viewing this thread

Top Bottom