Closed Thread
Results 1 to 2 of 2

Thread: Compare user entered date to date in table

  1. #1
    Barn Regular tuxalot is on a distinguished road tuxalot's Avatar
    Join Date
    Feb 2009
    Posts
    89
    Rep Power
    4

    Compare user entered date to date in table

    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!

  2. #2
    Lightning Master AOG123 is a jewel in the rough AOG123 is a jewel in the rough AOG123 is a jewel in the rough AOG123 is a jewel in the rough AOG123's Avatar
    Join Date
    Mar 2008
    Location
    Fortress Of Solitude
    Posts
    394
    Rep Power
    7

    Something along the lines of: -

    Code:
    Private Sub Start_Date_Exit(Cancel As Integer)
    If Me.Start_Date = Forms![FrmMain]![Date of Injury] Then
    MsgBox ("Your Message Here")
    Me.Start_Date = Null
    Cancel = True
    
    Else
    'do whatever here
    
    End If
    
    End Sub
    
    As you can see, this goes in the On Exit event of the Text box,
    If i helped you, make me famous by clicking the

Closed Thread

Similar Threads

  1. Date problem
    By todd2006 in forum ASP Development
    Replies: 11
    Last Post: March 9th, 2009, 03:49 PM
  2. Date problem
    By todd2006 in forum ASP Development
    Replies: 1
    Last Post: September 1st, 2008, 07:15 PM
  3. keep time and date
    By javier_83 in forum Microsoft Access
    Replies: 6
    Last Post: August 15th, 2008, 07:03 PM
  4. date problem
    By todd2006 in forum SQL Development
    Replies: 2
    Last Post: July 7th, 2008, 02:52 PM
  5. Nullable(Of Date)
    By richyrich in forum .NET Development
    Replies: 1
    Last Post: June 5th, 2008, 03:28 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO