Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    cpFAL96 is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2025
    Posts
    7

    Avoiding the "can't save the record at this time" pop-up

    Hey everyone. I just started learning in Access (came over from Excel a few weeks ago). I'm in the process of developing a database for my firm. It'll include detailed client information, user log-ins, allow users to make billing entries, etc.



    I am getting stuck on this one form that I'm building. It is a very simple form that is supposed to update a job description and rate. Basically the user should be able to select the job they want to edit from a combo box, it brings up the description and rate for that job, they click edit, and they can make the change. They should also be able to add new records by clicking an "add new" button.

    For the most part it is working, but I'm trying to build in fail-safes for when the users don't work it perfectly. Currently when I click on "add new" and then close the form, I'm getting the error message that "Access can't save the record at this time." Have played with using different events like form_unload or form_beforeclose but it's not working.

    This is the all the code I have in this form's module currently -

    Code:
    Private Sub EditJobRefreshBtn_Click() 'refresh/requery manual button
    Me.Refresh
    Me.JobDescriptionBx.Requery
    Me.JobDescriptionBx.SetFocus
    
    'lock fields when moving to new record
    Me.EditJobTxt.BackColor = RGB(245, 245, 245)
    Me.EditJobTxt.Locked = True
    Me.EditHourlyRateTxt.BackColor = RGB(245, 245, 245)
    Me.EditHourlyRateTxt.Locked = True
    
    End Sub
    
    
    Private Sub Form_AfterInsert() 'refresh/requery after new record is added
    '(so that job list is updated)
    
    Me.Refresh
    Me.JobDescriptionBx.Requery
    
    End Sub
    
    
    Private Sub Form_Current() 'runs when form is opened or goes to a different record
    
    Me.JobDescriptionBx.SetFocus
    
    'lock fields when moving to new record
    Me.EditJobTxt.BackColor = RGB(245, 245, 245)
    Me.EditJobTxt.Locked = True
    Me.EditHourlyRateTxt.BackColor = RGB(245, 245, 245)
    Me.EditHourlyRateTxt.Locked = True
    
    End Sub
    
    
    Private Sub Form_BeforeUpdate(Cancel As Integer) 'triggered when user changes a value
    
    'if job description is blank and it's a new record, cancel entry (no save)
    If Nz(Me.EditJobTxt, "") = "" Then
        If Me.NewRecord Then
            Me.Undo
            Cancel = True
            Exit Sub
        'if job description is blank on a existing record, require description
        Else
            MsgBox "Job description is required. Record will not be saved.", vbExclamation, "Missing information"
            Cancel = True
            Me.EditJobTxt.SetFocus
            Exit Sub
        End If
    End If
    
    'If rate is null or blank, make it 0
    If IsNull(Me!EditHourlyRateTxt) Or Me!EditHourlyRateTxt = "" Then
        Me.EditHourlyRateTxt = 0
    End If
    
    End Sub
    
    
    Private Sub AddJobBtn_Click() 'adds new record
    
    'go to new record
    DoCmd.GoToRecord , , acNewRec
    
    'unlock fields
    Me.EditJobTxt.BackColor = RGB(255, 255, 255)
    Me.EditJobTxt.Locked = False
    Me.EditHourlyRateTxt.BackColor = RGB(255, 255, 255)
    Me.EditHourlyRateTxt.Locked = False
    
    Me.EditHourlyRateTxt.Value = ""
    Me.EditJobTxt.Value = ""
    Me.EditJobTxt.SetFocus
    
    End Sub
    
    
    Private Sub EditJobBtn_Click() 'enables editing
    
    Me.EditJobTxt.BackColor = RGB(255, 255, 255)
    Me.EditJobTxt.Locked = False
    Me.EditHourlyRateTxt.BackColor = RGB(255, 255, 255)
    Me.EditHourlyRateTxt.Locked = False
    Me.EditJobTxt.SetFocus
    
    End Sub
    
    
    Private Sub JobDescriptionBx_AfterUpdate() 'updates the job description and rate fields based on user's selection in combo box
    
    If Not Me.NewRecord Then
    
    Dim rs As DAO.Recordset
    Set rs = Me.Recordset.Clone
    rs.FindFirst "JobID = " & Me.JobDescriptionBx
    If Not rs.NoMatch Then Me.Bookmark = rs.Bookmark
    
    End If
    
    
    Me.EditJobTxt.BackColor = RGB(245, 245, 245)
    Me.EditJobTxt.Locked = True
    Me.EditHourlyRateTxt.BackColor = RGB(245, 245, 245)
    Me.EditHourlyRateTxt.Locked = True
    
    End Sub
    Can anyone help me figure out what's going wrong? Would really appreciate it, thank you!
    Attached Files Attached Files
    Last edited by cpFAL96; 08-19-2025 at 04:21 PM.

  2. #2
    cpFAL96 is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2025
    Posts
    7
    Here's a screenshot of what the form looks like visually.
    Click image for larger version. 

Name:	Access help screenshot.PNG 
Views:	17 
Size:	13.1 KB 
ID:	53193

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,555
    Where is the code for the Save button?
    Best to upload a copy of the DB with just enough to see the issue.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    cpFAL96 is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2025
    Posts
    7
    Quote Originally Posted by Welshgasman View Post
    Where is the code for the Save button?
    Best to upload a copy of the DB with just enough to see the issue.
    Sorry, it is the "refresh" button.

  5. #5
    cpFAL96 is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2025
    Posts
    7
    Quote Originally Posted by Welshgasman View Post
    Best to upload a copy of the DB with just enough to see the issue.
    My file size is too big too upload here apparently, even with just the form and the corresponding table with only 4 records.

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,555
    Quote Originally Posted by cpFAL96 View Post
    My file size is too big too upload here apparently, even with just the form and the corresponding table with only 4 records.

    You could try a Compact and then zip, then upload?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  7. #7
    xps35's Avatar
    xps35 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jun 2022
    Location
    Schiedam, NL
    Posts
    299
    I think you're making things far too complicated for yourself. If you want to build a complete database this way, it'll take a while.
    You don't need any code at all to edit or enter data. Just link the table you want to edit to the form and the table fields to the form fields, and everything you type into a field on the form will go directly into the table.
    Groeten,

    Peter

  8. #8
    cpFAL96 is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2025
    Posts
    7
    Quote Originally Posted by xps35 View Post
    I think you're making things far too complicated for yourself. If you want to build a complete database this way, it'll take a while.
    You don't need any code at all to edit or enter data. Just link the table you want to edit to the form and the table fields to the form fields, and everything you type into a field on the form will go directly into the table.
    If it was just me using the database I would, but I'm trying to make it more user-friendly for everyone else. I'm concerned about accidental edits/additions leading to messy data.

  9. #9
    cpFAL96 is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2025
    Posts
    7
    Quote Originally Posted by Welshgasman View Post

    You could try a Compact and then zip, then upload?
    I got it compacted enough to upload, it's attached on my original post now!

  10. #10
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,422
    I agree with the sentiment in post 7. Anyway, when adding a record, you are putting it in edit mode with this

    Me.EditHourlyRateTxt.Value = ""
    Me.EditJobTxt.Value = ""

    I checked the table field settings and based on those, confess that the reason escapes me at the moment (but then I'm multi tasking at the moment so maybe I'm not 100% focused). Anyway, I don't see the need for it. A new record typically doesn't require you to set null values or empty strings in fields. It starts out that way by default. If you remove those lines the problem should go away.

    The posted db doesn't give much insight into what the rest of the tables will look like, and your comment about coming over to Access from Excel makes me wonder if you'll set upt the other tables like you would for spreadsheets.
    Last edited by Micron; 08-19-2025 at 05:46 PM. Reason: clarification
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  11. #11
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,555
    Quote Originally Posted by cpFAL96 View Post
    If it was just me using the database I would, but I'm trying to make it more user-friendly for everyone else. I'm concerned about accidental edits/additions leading to messy data.
    That can all be handled with form events.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  12. #12
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,555
    Works fine for me?
    I amended computer work to 90, and added Access at 120.
    Attached Files Attached Files
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  13. #13
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Office 365
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    The error occurs when you try to edit an existing entry in the combobox.
    You have set Limit to List = Yes so you can't edit it.
    Try changing Limit to List to No. You may need to changing other settings for the combo as well (or re-create it)
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  14. #14
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,422
    The error occurred for me as stated in the OP. Simply open form, click add new then close form. I had to use right click menu to close.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  15. #15
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,555
    Quote Originally Posted by Micron View Post
    The error occurred for me as stated in the OP. Simply open form, click add new then close form. I had to use right click menu to close.
    OK, just doing that, I got that error.
    However commenting out

    Code:
    'Me.EditHourlyRateTxt.Value = ""
    'Me.EditJobTxt.Value = ""
    in the AddJobBtn code removes that error?

    No need to set the controls if you have just issued a DoCmd.GoToRecord , , acNewRec with what you have with the tables at present.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 07-12-2023, 08:24 AM
  2. Replies: 3
    Last Post: 02-13-2019, 01:49 AM
  3. Avoiding "#Error" in Calculated Field
    By Aaron5714 in forum Forms
    Replies: 1
    Last Post: 01-22-2013, 03:43 PM
  4. Can not close pop up form after second pop was opened
    By snoopy2003 in forum Programming
    Replies: 2
    Last Post: 03-09-2011, 02:56 AM
  5. Replies: 1
    Last Post: 01-08-2011, 06:34 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