By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,811 Members | 785 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,811 IT Pros & Developers. It's quick & easy.

Compare user entered date to date in table

P: 200
I have a textbox, [Date of Injury] on [FrmMain] with a record source [TblEmployeeInjury]. FrmMain is a tabbed form showing injury data for a given EmployeesID. I have a textbox, [Start Date] on a subform [FrmMain].[FrmDateHistory] with [TblDateHistory] as the record source. [Start Date] is entered by a user and saved to the table by clicking a save button on the subform. Both date entries are in Short Date format and entered by Date Pickers. I would like an On Click event to fire when the save button is clicked which would compare if [Date of Injury] and [Start Date] are equal. No other comparison is required. If they are equal, I would like a MsgBox to show, and after the MsgBox is closed the set focus would return to [Start Date].

I'm very new to Access so hopefully someone can assist with this.

Any help is very much appreciated!
Feb 27 '09 #1
Share this Question
Share on Google+
2 Replies

Expert 100+
P: 1,923
Add the following code to the end of the existing code for your save button.

Expand|Select|Wrap|Line Numbers
  1. If Me.[StartDate] = Me.Parent.[Date of Injury] Then
  2.     MsgBox "Your message."
  3.     Me.[StartDate].SetFocus
  4. End If
Feb 27 '09 #2

P: 200
Thanks pup! I appreciate the fast response.

Feb 27 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.