Results 1 to 2 of 2
  1. #1
    Huddle is offline Competent Performer
    Windows XP Access 2010 64bit
    Join Date
    Jun 2010
    Posts
    318

    Date checking code error

    I've written the below code wrong and am getting this error. "Ambiguous name detected".
    The field names are all correct so I'm sure it has something to do with how it is written. I'm wanting to check each date to make sure they are put in properly.
    Please let me know where I went wrong.



    Private Sub OK_Click()
    If Me.FYDate < Me.FirstDay Then
    MsgBox "The FY Date cannot be before the Fist Date", 0, "Error"

    Me.FYDate = Null


    Me.FYDate.SetFocus
    Exit Sub
    End If
    Me.Visible = False
    End Sub
    Private Sub OK_Click()
    If Me.FirstDay < Me.SeventhDay Then
    MsgBox "The First Date cannot be before the Seventh Date", 0, "Error"

    Me.FirstDay = Null
    Me.FirstDay.SetFocus
    Exit Sub
    End If
    Me.Visible = False
    End Sub

    Private Sub OK_Click()
    If Me.SeventhDay < Me.FourteenthDay Then
    MsgBox "The Seventh Date cannot be before the Fourteenth Date", 0, "Error"

    Me.SeventhDay = Null
    Me.SeventhDay.SetFocus
    Exit Sub
    End If
    Me.Visible = False
    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    You can only have 1 sub named "Private Sub OK_Click()". Put all your code inside one instance of it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Error Checking Boxes
    By CementCarver in forum Access
    Replies: 2
    Last Post: 06-12-2013, 04:27 PM
  2. Press Alt key to disable date-checking code in program
    By LindaRuble in forum Programming
    Replies: 2
    Last Post: 05-21-2013, 09:02 AM
  3. checking date when recordcount > 0
    By JeroenMioch in forum Programming
    Replies: 14
    Last Post: 03-05-2013, 12:39 PM
  4. Error Checking within Form
    By phd4212 in forum Forms
    Replies: 1
    Last Post: 05-09-2012, 02:46 PM
  5. Date error checking
    By oediaz in forum Programming
    Replies: 2
    Last Post: 03-26-2010, 12:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums