Results 1 to 5 of 5
  1. #1
    Perfac's Avatar
    Perfac is offline Expert
    Windows 10 Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618

    Current Event on form.

    a. A month ago, I posted a similar thread here. I still don't know the exact explanation but learnt a bit more, and still have a challenge.
    b. My app is set up with 3 "User permission levels". Capturer, Manager, Programmer. When a capturer logs in, editing or deleting is not possible.
    c. When a manager or programmer logs in, the Enable button works. All of my 150 main forms have similar set up, they all have an enable button.
    d. I experienced that certain VBA code (not all) under the "Current Event", disabled VBA code that is under the "Load Event", then Capturers can edit and delete.
    e. I moved the troubled VBA code, to other events (e.g., On Open) and experienced different errors.
    f. For a long time, I experienced that VBA that sets visibility of fields, or VBA that enable buttons did not cause the error. But this week it did error.
    g. I have a test page, which I will post here a bit later.
    Click image for larger version. 

Name:	221212a.png 
Views:	20 
Size:	68.1 KB 
ID:	49295

  2. #2
    Perfac's Avatar
    Perfac is offline Expert
    Windows 10 Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    A few times when Access reaction differs in result when I take exactly the same action, and it wastes hours, I feel like a desperate fool at the end of my rope, smile. Below is the VBA load event and enable button event.
    Click image for larger version. 

Name:	221212b.png 
Views:	19 
Size:	7.7 KB 
ID:	49296

  3. #3
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    I experienced that certain VBA code (not all) under the "Current Event", disabled VBA code that is under the "Load Event", then Capturers can edit and delete.
    Technically, that makes no sense. In terms of the following events, Open is first, Load is next, Current is next. OK, it's not exactly those 3 in the sequence, but that is the order of those 3. Methinks I provided you with a link for forms, subforms, controls, etc. in a prior thread?

    Any disabling/enabling has to be done in the Current event IF you can navigate through records - unless you just want to lock things up and use buttons to adjust permissions. But you lock/unlock with a button, then what? You move to another record and then find permissions are not correct for that record so you have to use the Current event to lock things up again? Might as well forget the button and just set permissions per record based on who's got the form open.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    Perfac's Avatar
    Perfac is offline Expert
    Windows 10 Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    My app is only used by two businesses since four years ago, sold the businesses, but trying to improve my app, still lots to do. I previously owned the businesses but recently semi-retired. This action always worked well so far. Every form when opened by a capturer, they cannot edit or delete. A manager or programmer can click the enable button to be able to delete or edit any time. Currently for years that VBA is under Open event like below. I always had a policy to make a process as simple and short as possible, if one click can be left out I should, so I am considering your last sentence not using buttons.

    Earlier last night I tested some VBA 5 times. I simply added a paragraph of VBA to Current event, 3 Times the result disabled the load event. 4th and 5th time the result was good and now it is working. Makes no sense as you say. My challenge is some code just continue causing my issue, probably because I am missing something or don't know. So far, I then found other solutions, but always keen to learn.
    Click image for larger version. 

Name:	221212c.png 
Views:	17 
Size:	12.8 KB 
ID:	49297

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Have you been asked not to post code as image? Copy/paste code between CODE tags - the # button on the post editor.

    Proper indentation would make your code easier to follow.

    Looks like SELECT CASE would be appropriate structure.

    Does that query have only one record?

    Code:
    Select Case DLookup("Uspele_IDb", "q01LoggedInUser")
        Case 66
             'do this
        Case 67
             'do this
        Case 68
             'do this
    End Select
    or
    Code:
    Dim intIDb As Integer
    intIDB = Nz(DLookup("Uspele_IDb", "q01LoggedInUser"),0)
    With Me
        .btn15Enable.Enabled = intIDb = 66
        .btn16DeleteOne.Enabled = intIDb = 66
        .btn07Progamming.Enabled = intIDb = 66
    End With
    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.

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

Similar Threads

  1. Getting run time error 2455 using Form Current event
    By brian11670 in forum Programming
    Replies: 8
    Last Post: 09-08-2021, 08:46 AM
  2. On Current Event Question
    By JeRz in forum Programming
    Replies: 2
    Last Post: 10-19-2016, 09:41 AM
  3. close Form from within a Form.current event
    By alextijuca in forum Access
    Replies: 7
    Last Post: 03-19-2015, 11:31 AM
  4. Replies: 3
    Last Post: 01-14-2015, 02:51 PM
  5. cbo Issue and On Current Event
    By buckwheat in forum Access
    Replies: 10
    Last Post: 08-29-2013, 11:39 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