Form 1 opens form 2 to matching record (1 Viewer)

Jonny45wakey

Member
Local time
Today, 01:28
Joined
May 4, 2020
Messages
44
Hi

I have a form "frmDayshift" which has field [shiftdate], this form has a cmd button when clicked i want it to open a second form "frmdayshiftprintcheck" to same record date as form 1 [shiftdate], form 2 date field = [checkdate]

ive tried vba such as:-

DoCmd.OpenForm "frmDayShiftprintcheck", , , "[CheckDate]=#" & Me.ShiftDate & "#"

But is doesnt seem to open to the right record.

Any ideas welcomed

Many thanks

Jonny
 
maybe try:

DoCmd.OpenForm "frmDayShiftprintcheck", , , "[CheckDate]=#" & Format$(Me.ShiftDate, "m/d/yyyy") & "#"
 
DoCmd.OpenForm "frmDayShiftprintcheck", , , "[CheckDate]=#" & Me.ShiftDate & "#"

But is doesnt seem to open to the right record.
Are you in the UK?

When constructing dates in SQL you must use an "unambiguous date format" which translates to "yyyy-mm-dd" or "mm/dd/yyyy"

Try adjusting to:
Code:
DoCmd.OpenForm "frmDayShiftprintcheck", , , "[CheckDate]=" & Format(Me.ShiftDate, "\#yyyy\-mm\-dd\#")

hth,

d
 
Hopefully you would have an autonumber and could just use that?
Much, much easier. :)
 
maybe try:

DoCmd.OpenForm "frmDayShiftprintcheck", , , "[CheckDate]=#" & Format$(Me.ShiftDate, "m/d/yyyy") & "#"
maybe try:

DoCmd.OpenForm "frmDayShiftprintcheck", , , "[CheckDate]=#" & Format$(Me.ShiftDate, "m/d/yyyy") & "#"

arnelgp, your solution worked perfectly, thankyou for solving this for me, much appreciated :)

REgards

Jonny
 

Users who are viewing this thread

Back
Top Bottom