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

    Question Can't Save Record for Current Date, but All Others Possible

    I have a form with a New Record button, a Save Record button, and a field with a date picker. I also have a simple VBA code that saves the last fields' values as a default on the Mouse Up event of Save Record.

    If I choose any date other than the current day, I can click Save Record and everything works fine. However, if I click New Record and then try Save Record, nothing happens.

    If I actually change or add a value to a field after clicking New Record and then click Save Record, it does save the record.

    Does anyone know how to fix this? Not sure why it only happens for the current date...

    I've tried:

    1) Having a value of a field change (in VBA) after clicking New Record in the Mouse Up event. It works but only once. This is okay, but if someone accidentally clicks New Record twice, then it won't work.


    2) I tried setting a field value to itself (in VBA) after clicking New Record in the Mouse Up event to see if that would somehow refresh itself. It didn't.


    3) I've tried New Record as VBA as well. It didn't work.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,954
    Think I need to review the project to track this down - if you want to provide it.
    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
    Here is a version of what I'm working with. I had to take out unnecessary information and split it to get it uploaded. If I need to give you it together I can put it up on ZShare quickly. EOSS-DB.accdbEOSS-DB_be.accdb

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,954
    The issue is with the form. Having only the table means nothing to analyse. Did you try zipping with Windows Compression after running Compact & Repair? Up to 2mb zip allowed as attachment.
    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.

  5. #5
    Heatshiver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2011
    Posts
    128
    Hi June7, thanks for the response. I did not try compression, but I will from now on

    As for only having a table, does that mean the issue would not exist if using the source as a query instead? If not, what could the form analyze to get the button functioning properly?

    BTW, this is the same project for the "Date Field Check against Saved Date" post that I am referring to.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,954
    Query or table, doubt the behavior will be different. I need form to analyse issue.
    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.

  7. #7
    Heatshiver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2011
    Posts
    128
    I kept it as one file and zipped it
    Attached Files Attached Files

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,954
    I tried to enter a record for current date but there already is a record for today. Date is primary key so can't have more than record for each date. I removed the record for today's date and added new record. Worked fine.

    Why prevent tab and enter keys to move out of the Date control? Have to go to mouse click. Very annoying.

    Personally, don't like date picker, requires mousing. I like to set up forms so can do everything from keyboard. Most of my forms can go beginning to end without lifting hands from the keyboard. Even command buttons have words on them (or associated labels) using the shortcut key designation with the & character so Alt+character will execute the command.

    The Save Record button might be unnecessary. A record is committed to table when move to another record, close form, or run code.
    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
    The problem I was having is that if you click the New Record button, and then try to Save, it doesn't do anything.

    It will work if you choose the date from the date picker instead; or if you click the New Record button, and then change or add a new value to one of the fields.

    ----

    I forget why I stopped them from tabbing or entering to move out of the date control, I think I had done it at the time to prevent them from leaving the date field if it was a value that would give an error if they used the Save Record button. It is likely unnecessary now.

    I don't like the date picker much either, but I need to idiot-proof this for the users as they may be used to Excel, but likely have never touched Access before.

    Save Record button is also for idiot-proofing, as likely these users won't be aware of CTRL + S.

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,954
    Here is what I experienced.

    The macros were driving me nuts (I don't use them) - converted to VBA so I could see the code easier and debug. Removed the code limiting tab and enter out of date box. Removed VBA MouseUp events. Put code from Command7 MouseUp into Click event.

    Apparently the defaults aren't enough to tell Access there is a record started and to save it. As soon as manually entered a value into a field (including a default field) and click Save the record is committed. Do you want record saved if only has the default value fields populated? I do something similar but instead of setting defaults I set values of fields. But you also do that with one field. So don't understand why this doesn't work. Wait, that's it - make Me.Start_Depth.Value = "911" the last line of Command7 Click (what you have as MouseUp) event. Like:

    DoCmd.GoToRecord , "", acNewRec
    Me.ctlSearch.Requery
    Me.Days.SetFocus
    Me.Start_Depth.Value = "911"

    Two events (Click and MouseUp) not needed, use only the Click events.
    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.

  11. #11
    Heatshiver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2011
    Posts
    128
    Thank you, I will try immediately!

  12. #12
    Heatshiver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2011
    Posts
    128
    Thank you, this worked.

    However, I had to keep the Requery macro on the MouseUp event of the Save Record button. For some reason, after saving the present day, the combobox would not requery when using VBA. But if I used the macro, it had no problem with the requery...

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

Similar Threads

  1. Replies: 1
    Last Post: 12-07-2011, 01:02 PM
  2. SQL Inner Join where date = current date
    By Tyork in forum Queries
    Replies: 2
    Last Post: 11-07-2010, 02:07 PM
  3. Comparing Date with current Date
    By ds_8805 in forum Forms
    Replies: 7
    Last Post: 03-31-2010, 09:31 PM
  4. Replies: 9
    Last Post: 03-19-2010, 10:37 AM
  5. Current Date Error
    By McFly in forum Database Design
    Replies: 4
    Last Post: 02-04-2010, 09:08 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