Results 1 to 15 of 15
  1. #1
    Synergy.ron@gmail.com is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2020
    Location
    washington
    Posts
    126

    Button not 'firing'

    i have a simple membership app. On the switchboard form there is a Quit button . When I click quit it is supposed to execute: a save and exit.
    Private Sub btn_Quit_Click()DoCmd.Save


    DoCmd.Beep
    MsgBox "File saved"
    DoCmd.Quit
    End Sub

    It will not fire the on click event. I put a breakpoint on the first line and it is no tripped. I have changed the name...no help.... I have recreated the event (several times) nada... Can you see what i am doing wrong? I just checked the form. NONE OF THE BUTTONS WORK.... HAVE I MESSED UP A SETTING?

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Your form load code doesn't make sense. If you're at BOF, you can't move previous, nor can you update a recordset unless you put it in edit 'mode'. In your code, there is nothing to 'save' in the recordset because you don't make any changes to it anyway.

    Otherwise, button code fired for me, so make sure db is in a Trusted Location.
    What do you want to save? You don't save record changes this way - only object changes such as forms/reports design or code edits.
    Last edited by Micron; 09-13-2021 at 05:07 PM. Reason: added info
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    ssanfu is offline Master of Nothing
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    In addition to Micron's comments, Access will save data when the form closes or the current record changes. Your "Quit" button also worked for me (have the same error when switchboard opens as Micron stated)

    This is the exit/quit code I use: I have a button names "cmdExit", with the code
    Code:
    Private Sub cmdExit_Click()
        If MsgBox("Exit Access?", vbYesNo, "Are You Sure?") = vbYes Then
            DoCmd.Quit
        End If
    End Sub

  4. #4
    Synergy.ron@gmail.com is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2020
    Location
    washington
    Posts
    126
    I have in the on load event this:
    Private Sub Form_Load()
    '====================================
    Code:
    Set db = CurrentDb
    Set rs = db.OpenRecordset("Utility", dbOpenTable)
         If rs.BOF Then
         rs.MovePrevious
         End If
      s3 = rs.Fields![serialnum]   'get existing serial
      s4 = rs.Fields![password]    'get existing pw
      auth = rs.Fields![Authorized]  'get existing 'auth '
      rs.Update
    I suspect i have a setting wrong,somewhere.....Setting a breakpoint in on load does not get noticed. whats up with that?

  5. #5
    ssanfu is offline Master of Nothing
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    If you open a form and the record set is at BOF (beginning of file), that would tell me that there are no records in the record set; therefore you would not be able to "MovePrevious" - you are already at the BOF.

    I am curious as to why you have "rs.Update" in the code?? Nowhere in this sub (Form_Load) do you have "rs.AddNew" or "rs.Edit".

  6. #6
    Synergy.ron@gmail.com is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2020
    Location
    washington
    Posts
    126
    You are right. As usual, it is my err.
    I had turned off a macro notificaton in File/Options. once I made that change....ba boom. everything is back. Thank you for the observations....

  7. #7
    Synergy.ron@gmail.com is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2020
    Location
    washington
    Posts
    126
    I suspect I have a similar problem. I can't find any macro reference in FILE/OPTIONS. can you be more specific as to location?

  8. #8
    ssanfu is offline Master of Nothing
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I've been over and over your code for the "Form_Load()" event for form "switchboard".
    I am at a total loss as to what you are trying to accomplish. You can't enter... well, anything.... even after the form opens.


  9. #9
    DittoBird's Avatar
    DittoBird is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Apr 2015
    Location
    Newfoundland & Labrador, Canada
    Posts
    59
    Don't most folks check for eof? I usually use both, i.e.:

    Code:
    with rs
         if .eof and .bof then
              Msgbox "No records or something"
              'Do stuff (close form, cancel = true if in Form_Open event, 
              'don't forget to handle err.number 2501 in proc that calls the form)
         else
              'Do stuff for the form or recordset or whatever
         end if
    end with

  10. #10
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,861
    Big peeve of mine.
    If you open a file and are at EOF, then you are also at BOF, as the file is empty.?

    I just test for EOF?
    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

  11. #11
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Maybe for a lot of people if it's good enough for AB it's good enough for the rest of us.
    http://allenbrowne.com/ser-29.html

    That's my reason anyway. I figure that IF it were possible to open a recordset and somehow end up at the bof or eof markers (perhaps from code whose action wasn't anticipated) then using both will avoid any unexpected results. Then there's code that works for years and someone posts here why it doesn't after an upgrade. It was sloppy but it worked for a time and the answer was to fix the code. Hopefully all that code you've written that way won't one day become unstable after the DAO library is upgraded.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  12. #12
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,861
    @Micron
    AB is talking about checking before a Move record pointer? So yes, rather than check EOF for MoveNext and BOF for MovePrevious, check them both at the same time?
    I am talking about just opening the file, no move involved.

    However, I am always up for being proved wrong, have been plenty of times, another few times is not going to hurt my feelings.
    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
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    AB is talking about checking before a Move record pointer?
    Sure, but isn't that one of the first things that is usually coded after the recordset is opened? Perhaps most common move (perhaps in error) would be MoveLast to get a record count, which should raise and error.

    I'm not saying anyone who codes your way is wrong. Just saying that the AB method seems more of a sure thing and I'm banking on future updates never being an issue for me.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  14. #14
    Synergy.ron@gmail.com is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2020
    Location
    washington
    Posts
    126
    It looks like the problem was/is in the security settings. MY APP HAS NO MACROS BUT IF I TURN ON 'ENABLE ALL MACROS THE PROBLEM DISAPPEARS.?????

    still seems weird.....

  15. #15
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Macros and code are considered to be the same thing when it comes to Trusted Locations - at least in Access. It's not like you can enable one and disable the other.
    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. NotInList Event Not Firing
    By mib1019 in forum Forms
    Replies: 17
    Last Post: 10-02-2020, 11:31 AM
  2. Key Down event not firing
    By GraeagleBill in forum Programming
    Replies: 4
    Last Post: 11-18-2016, 12:45 AM
  3. AfterUpdate not firing
    By GraeagleBill in forum Forms
    Replies: 7
    Last Post: 04-24-2016, 11:42 PM
  4. OnClick not firing
    By richard1941 in forum Access
    Replies: 4
    Last Post: 01-06-2015, 05:27 PM
  5. AfterUpdate not firing
    By newvb in forum Forms
    Replies: 4
    Last Post: 09-29-2011, 04:55 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