dixiedog79
New Member
- Joined
- Jan 31, 2012
- Messages
- 8
Hi all,
Can anyone help? I have a textbox (formated as medium date) in a form which users will enter a date. I then have a table with a list of dates (again formated as medium date). What I am trying to achieve is for a User to enter a date into the textbox and if it matches a date in the table, then the user can move on with the form. If however they enter a date which isn't in the table, then he says that they need to try again.
The code looks okay, but for some reason it isn't finding any correct data in the table. Can you help... the code is this...
[FONT="]Private Sub DateFrom_AfterUpdate()[/FONT]
[FONT="][/FONT]
[FONT="]'If field is populated then move on.[/FONT]
[FONT="] If Not IsNull(Me.DateFrom) Then
[/FONT]
[FONT="]
[/FONT]
[FONT="]'If TextBox 'DateFrom' has data which is in table 'tblDatesFiltered' and Row 'strDateCode', then say 'Please Enter a Return Date' - which is the next field. However if there is no match then say '[/FONT][FONT="]Date Not Valid (are you entering a weekend or bank holiday?) - Please Try Again'[/FONT][FONT="].
[/FONT]
[FONT="]If DCount("[strDateCode]", "[tblDatesFiltered]", "[strDateCode]='" & Me.DateFrom) = True Then[/FONT]
[FONT="]MsgBox "Please Enter a Return Date!"[/FONT]
[FONT="]Me.DateTo.SetFocus[/FONT]
[FONT="]Else[/FONT]
[FONT="]MsgBox "Date Not Valid (are you entering a weekend or bank holiday?) - Please Try Again"[/FONT]
[FONT="]Me.DateFrom.SetFocus[/FONT]
[FONT="]End If[/FONT]
[FONT="] End If[/FONT]
[FONT="]End Sub[/FONT]
Hope this makes sence? Any help would be appreciated!!!
Thanks
Paul
Can anyone help? I have a textbox (formated as medium date) in a form which users will enter a date. I then have a table with a list of dates (again formated as medium date). What I am trying to achieve is for a User to enter a date into the textbox and if it matches a date in the table, then the user can move on with the form. If however they enter a date which isn't in the table, then he says that they need to try again.
The code looks okay, but for some reason it isn't finding any correct data in the table. Can you help... the code is this...
[FONT="]Private Sub DateFrom_AfterUpdate()[/FONT]
[FONT="][/FONT]
[FONT="]'If field is populated then move on.[/FONT]
[FONT="] If Not IsNull(Me.DateFrom) Then
[/FONT]
[FONT="]
[/FONT]
[FONT="]'If TextBox 'DateFrom' has data which is in table 'tblDatesFiltered' and Row 'strDateCode', then say 'Please Enter a Return Date' - which is the next field. However if there is no match then say '[/FONT][FONT="]Date Not Valid (are you entering a weekend or bank holiday?) - Please Try Again'[/FONT][FONT="].
[/FONT]
[FONT="]If DCount("[strDateCode]", "[tblDatesFiltered]", "[strDateCode]='" & Me.DateFrom) = True Then[/FONT]
[FONT="]MsgBox "Please Enter a Return Date!"[/FONT]
[FONT="]Me.DateTo.SetFocus[/FONT]
[FONT="]Else[/FONT]
[FONT="]MsgBox "Date Not Valid (are you entering a weekend or bank holiday?) - Please Try Again"[/FONT]
[FONT="]Me.DateFrom.SetFocus[/FONT]
[FONT="]End If[/FONT]
[FONT="] End If[/FONT]
[FONT="]End Sub[/FONT]
Hope this makes sence? Any help would be appreciated!!!
Thanks
Paul