SOS Validate Date

brucey54

Registered User.
Local time
Today, 12:51
Joined
Jun 18, 2012
Messages
155
Hi folks, need some help please, trying to pass a date field from a Form and check if this date already exists within a table if so run this macro.

This is what I have so far...

Private Sub Command38_Click()
If DCount("*", "TblDietPlan", "[MealDate] = <> txtCusDate Then

stDocName = "McrPrint_LabelsWklyCR"
DoCmd.RunMacro stDocName


Else
stDocName1 = "McrReOrderDietCusDate"
DoCmd.RunMacro stDocName1
stDocName2 = "McrPrint_LabelsWklyCR"
DoCmd.RunMacro stDocName2

End If
End Sub
 
Try this,
Code:
Private Sub Command38_Click()
    If DCount("*", "TblDietPlan", "[MealDate] [COLOR=Red][B]= " & Format(txtCusDate, "\#mm\/dd\/yyyy\#")) <> 0 Then[/B][/COLOR]
       [COLOR=Green] 'A date provided exists in the table[/COLOR]
        stDocName = "McrPrint_LabelsWklyCR"
        DoCmd.RunMacro stDocName
    Else
        stDocName1 = "McrReOrderDietCusDate"
        DoCmd.RunMacro stDocName1
        stDocName2 = "McrPrint_LabelsWklyCR"
        DoCmd.RunMacro stDocName2
    End If
End Sub
 
Thanks Paul, it worked, where do I send the beer tokens to -
Merry Christmas :-)
 

Users who are viewing this thread

Back
Top Bottom