Results 1 to 9 of 9
  1. #1
    Heatshiver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2011
    Posts
    128

    Question Date Field Check against Saved Date?

    I have a combobox that checks for saved dates and allows someone to choose from the drop-down if they want to go back and change values in the fields from that date. I have a date field with a date picker to choose a date that has yet to be saved.

    My issue is that if a person uses the date picker and chooses an existing date (instead of the combobox), I get an error for the combobox code once they try to save.

    I was thinking that a simple VBA code in the Lost Focus event of the date picker could fix this. It would say something to the effect of:



    If Date Chosen = Existing Date Then
    MsgBox("Use combobox for existing dates")
    datepickerField.SetFocus
    datepickerField.Clear
    End If

    Essentially, the user would be unable to choose an existing date from the date picker, and would have to use the combobox instead.

    I don't know how to write out the first part "Date Chosen = Existing Date". All I could think of was "DTPicker0.Value =" or "Me.DTPicker0.Value = ", but wasn't sure how to check it against existing dates.

    Thanks!

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Clarify. Dates are existing where?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Heatshiver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2011
    Posts
    128
    Sorry. The existing dates would exist in a table with a field that has a datatype of date/time. The code would be checking to see if the date chosen by the date picker already exists in that table.

  4. #4
    apotter is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2012
    Posts
    5
    I have used date pickers in the past that allow for a collection of dates (from your table for example) that are not available for selection. Is this a possibility with your date picker?

  5. #5
    Heatshiver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2011
    Posts
    128
    @apotter that would be a perfect solution for this! Please share!

  6. #6
    apotter is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2012
    Posts
    5
    Sorry, I don't have Access 2010 or any experience using a date picker in Access...I was just pointing out that I have used date pickers in the past that have this functionality built in...and was wondering out loud that perhaps this could be true of the control that you are using?

  7. #7
    Heatshiver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2011
    Posts
    128
    Still, now that I know that there is something like this, I can have a good search in the meantime.

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Perhaps a DLookup.

    If Not IsNull(DLookup("fieldname", "tablename","fieldname=#" & Me.datecontrolname & "#")) Then
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    Heatshiver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2011
    Posts
    128
    You're a genius June7! I think that worked for me and solves my issue!

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

Similar Threads

  1. Best way to check date.
    By Playerpawn in forum Access
    Replies: 1
    Last Post: 10-31-2011, 02:39 PM
  2. Getting Just the Date part of Date/Time field
    By GaryElwood in forum Reports
    Replies: 7
    Last Post: 09-28-2011, 09:58 AM
  3. Replies: 1
    Last Post: 02-06-2011, 06:36 PM
  4. Set date field on subform to date variable
    By laavista in forum Access
    Replies: 4
    Last Post: 06-30-2010, 06:32 PM
  5. set date field on form to date variable
    By laavista in forum Access
    Replies: 3
    Last Post: 06-28-2010, 03:03 AM

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