Date form issues (1 Viewer)

bk1010

Registered User.
Local time
Today, 12:35
Joined
Nov 16, 2009
Messages
16
All,

I'm trying to open a form from another subform based on dates, please see vba:

Option Explicit
Private Sub Sub_UserID_Click()
DoCmd.OpenForm "frm_Task_Details", , , "[TDate] = #" & Me.Sub_Task_Date & "#"
End Sub

However, some dates (eg, 12/08/2019) will open the form correctly but some dates (eg, 07/08/2019, 09/08/2019) will return a blank form. I have checked the formatting and the dates seems correct (dd/mm/yyyy).:banghead:

I cannot understand why, does anyone have any ideas or solution to resolve this issue?

Thanks, in advance,
BK
 

Minty

AWF VIP
Local time
Today, 12:35
Joined
Jul 26, 2013
Messages
10,370
You'll need to ensure that the date is formatted "mm/dd/yyyy" , or in fact better as it's completely unambigous "yyyy-mm-dd" ;

Code:
Option Explicit
Private Sub Sub_UserID_Click()
    DoCmd.OpenForm "frm_Task_Details", , , "[TDate] = #" & format (Me.Sub_Task_Date,"yyyy-mm-dd") & "#"
End Sub

An explanation is here http://allenbrowne.com/ser-36.html along with some tips on dealing with it going forwards.
 
Last edited:

bk1010

Registered User.
Local time
Today, 12:35
Joined
Nov 16, 2009
Messages
16
Minty,

Thank you so much, it's worked perfectly!
 

Users who are viewing this thread

Top Bottom