Results 1 to 10 of 10
  1. #1
    bubai is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Nov 2014
    Location
    Dhaka
    Posts
    162

    Form's BeforeUpdate Event problem.

    I have set a code to give me a reminder message that content of my form has been updated. The code is as follows:

    Code:
    Private Sub Form_BeforeUpdate(Cancel As Integer)
    
    
    If MsgBox("Brand names have been altered." & vbNewLine & vbNewLine & "Wanna SAVE your changes?" & vbNewLine, vbYesNo + vbQuestion, "Save this Record?") = vbNo Then
          Me.Undo
       End If
    End Sub
    But every time I put in a value in the first control, which happens to be the ID and try to move to next control the message box appears and don't let me finish the other controls of the record.
    I want the message box to fire only when I move to next record.

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,858
    You do not put a value in the ID, Access does that?
    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

  3. #3
    bubai is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Nov 2014
    Location
    Dhaka
    Posts
    162
    Quote Originally Posted by Welshgasman View Post
    You do not put a value in the ID, Access does that?
    No I put the ID value myself. It is a small table used as a Lookup table.

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,858
    Works fine for me?
    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

  5. #5
    bubai is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Nov 2014
    Location
    Dhaka
    Posts
    162
    Quote Originally Posted by Welshgasman View Post
    Works fine for me?
    Reason behind is to save on file size.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    This is editing record in the lookup table? Why would manual input of an ID into a Number field save file size more than an ID autonumber field?

    What is the form's RecordSource - table or query?
    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
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    I could only see this happening if that control was the only bound control for the record or you just happen to have the same code for the before or after update events for the control itself.

    Also, I agree that it makes little sense to not use autonumber (long integer) because it occupies the same size/space on disk as a normal long if that's what you're using. You could only save space if you used number size of byte or integer and that save would be minuscule when compared to the 2Gb allowed for the file size. Not only that, you now have to worry about entering only unique values, and the number of records if using byte is very limited compare to the other types.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #8
    bubai is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Nov 2014
    Location
    Dhaka
    Posts
    162
    Quote Originally Posted by Micron View Post
    I could only see this happening if that control was the only bound control for the record or you just happen to have the same code for the before or after update events for the control itself.

    Also, I agree that it makes little sense to not use autonumber (long integer) because it occupies the same size/space on disk as a normal long if that's what you're using. You could only save space if you used number size of byte or integer and that save would be minuscule when compared to the 2Gb allowed for the file size. Not only that, you now have to worry about entering only unique values, and the number of records if using byte is very limited compare to the other types.
    You are right- I am using Byte datatype. Both in the lookup table and the feeding table. 256 number of brands will be enough for me.
    However, the only event on that form is BefforeUpdate. I think all of the controls are bound controls. First is ID which is primary key Byte. Second is a Foreign key Combobox. Third is the textbox.
    Am I missing any basic here?

  9. #9
    bubai is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Nov 2014
    Location
    Dhaka
    Posts
    162
    Quote Originally Posted by June7 View Post
    This is editing record in the lookup table? Why would manual input of an ID into a Number field save file size more than an ID autonumber field?

    What is the form's RecordSource - table or query?
    Yes the form is editing the lookup table. I am using Byte as the primary key ID.
    Record Source is a table.

  10. #10
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Well, if there is no embedded macro that you forgot about, or no control with a BeforeUpdate event (which I don't think you've exactly clarified because both forms and controls use that event) then I'm out of ideas. I still don't get how the 2 byte per record means anything significant, especially over only 255 records (I believe the max value for byte is 255, not 256 - not that it seems to matter in this case). Perhaps your only option (assuming my latest points are of no help) is to post a copy here (compact/repair copy then zip).

    EDIT - then again, I suppose you could start with 0 and reach 256 record count.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 5
    Last Post: 06-18-2020, 02:42 AM
  2. BeforeUpdate Event to Create New Copy of Current Record
    By breakingme10 in forum Programming
    Replies: 6
    Last Post: 06-29-2018, 10:15 AM
  3. Replies: 4
    Last Post: 05-04-2017, 01:16 AM
  4. Using Me.Dirty in a BeforeUpdate event procedure.
    By MatthewGrace in forum Programming
    Replies: 3
    Last Post: 11-30-2014, 12:40 PM
  5. Subform Events Has No BeforeUpdate Event
    By CementCarver in forum Programming
    Replies: 1
    Last Post: 06-25-2013, 01:53 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