Kamis, 04 Februari 2016

RE: [MS_AccessPros] Re: Form Load or On Open question


Now() contains a time element #2/4/2016 10:50:42 AM# so it will only briefly equal a date only expression. Plus you are comparing a date with a string which is never a good idea. Always have the same data type on both sides of the "=".
I would try:
If Format(Me.txtTodaysDate,",m/d/yyyy") = "2/4/2016" Then
Or better:
If DateValue(Me.txtTodaysDate) = #2/4/2016# Then
However I don't understand why you would hard-code "2/4/2016" into your VBA. I assume this is just for testing.
Duane Hookom, MVP
MS Access

To: MS_Access_Professionals@yahoogroups.com
From: MS_Access_Professionals@yahoogroups.com
Date: Thu, 4 Feb 2016 08:41:50 -0800
Subject: [MS_AccessPros] Re: Form Load or On Open question

So I tried to see if the code even sees the date and changed the code to below. I get the Ho there message box. So it does not see the date probably. The text box has a control source of =Now()

Private Sub Form_Load()
If Me.txtTodaysDate = "2/4/2016" Then
'   DoCmd.CopyObject , "Jim", acTable, "tblMessages"
MsgBox "Hi there"
MsgBox "Ho there"
   End If
 MsgBox "The tblMessages table has been copied with the name of tblMessages-1-2-2017" & vbCrLf & _
" and a message has been sent to notify the users of the copied table."
End Sub


Posted by: Duane Hookom <duanehookom@hotmail.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (3)



Tidak ada komentar:

Posting Komentar