Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Perfac's Avatar
    Perfac is offline Expert
    Windows 10 Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618

    One part VBA nullifying another?

    See attachment.
    a. In my application on most VBA code pages the first Paragraph in red starts with the purpose that a user without permission cannot change existing info.
    b. An enable button is set up and users with permission can click and they are allowed to edit and delete information. All work well.
    c. Adding the Paragraph in blue, the experience is that opening the form existing info can be edited or deleted by a user without permission. Adding the blue, nullify the code in red?
    d. I tried other "form events" which returned different errors? As always I know there is a solution, must just find it.
    e. I will try to set up a small Access dbase that displays this issue and attach it.

    Click image for larger version. 

Name:	220917B.png 
Views:	15 
Size:	15.3 KB 
ID:	48739

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,914
    What is the point of the second If?
    It is either Null or not?

    I cannot see how that blue cancels out the red? Are you resetting the Allow back to not allowing?, else look elswhere for your code that allows amendments.
    As always if you walk through your code, you can see what Allow options are still set at?

    Start learning to debug your code at the basic level. That is what I have always done. It might be slower, but at least I get it right.
    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
    Perfac's Avatar
    Perfac is offline Expert
    Windows 10 Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    Thanks. I tested it by process of elimination to find the error, battled a bit. It makes no sense to me. There are quite a bit other code on the code page, but as said. When I delete the code in blue the effect of the stuff in red is perfect. When I put the blue code back the red code doesn't work. I will now make time to put all in a small DB to attach here.

  4. #4
    Perfac's Avatar
    Perfac is offline Expert
    Windows 10 Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    Open attached little part of DB. Test001
    a. Open first form f01EducationalInstit. First thing try to add a character at the end of Centurion Acadamy. It will allow it, it should not. Should after clicking enable.
    b. Open f01EducatnlInstitType, first try adding any character at the end of "Type". It will not, that is correct.
    c. If the blue code above is removed from code page of f01EducationalInstit, then it works.
    d. Any solution will do.
    Attached Files Attached Files

  5. #5
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,651
    Unless I'm doing something wrong, I can't reproduce your error. It appears to work for me.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  6. #6
    Perfac's Avatar
    Perfac is offline Expert
    Windows 10 Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    Some challenges get fixed when I reproduce exactly the same code or design. But I have done this over and over and it stays the same. The code in blue causes the error. I must do something different.

  7. #7
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,914
    Well I can replicate the issue, but those properties have not been amended?
    I put a Debug.Print in Load and Current events, and what is displayed is shown below.

    Current Deletions False
    Current Edits False
    Load Deletions False
    Load Edits False
    Current Deletions False
    Current Edits False
    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

  8. #8
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,914
    I can edit only on first entry.
    When I go to the subform and then back to the main form, it is not editable?
    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

  9. #9
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,914
    Quote Originally Posted by moke123 View Post
    Unless I'm doing something wrong, I can't reproduce your error. It appears to work for me.
    Moke, on first entry to form add a character to institution name.
    I can do it, but if I click into the subform then back into mainform, it will not allow edits.

    Blowed if I can see how he has done it?

    Edit: I'll have to give up, I cannot see what you have done to make this happen. None of the code should affect those properties and the display confirms that.
    Need an experienced person to work out what you have done.

    You can add that code to the type form but comment out the image and that does not affect the type form? I cannot even see where that Me!Images_IDa is on the first form?
    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

  10. #10
    Perfac's Avatar
    Perfac is offline Expert
    Windows 10 Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    I chose not to allow changes on most sub forms, it is locked in this case on the Data tab. As I said and may repeat.
    a. The second form return the result I want.
    b. The first form link to images which the second doesn't, therefore the blue code fetches the Image tables ID to store in Images_IDa.
    c. I am not experienced enough to make sense here about the error, but I do have another solution, though still hoping to do it this way.
    d. My app got about 250 forms. Tough to go through 150 to fix them 1 by 1.

  11. #11
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,914
    Yes, you appear to have created one form and just pretty much copied it for the others?
    I am at a loss as to how you have done it.

    Even if you set the properties to No in the form, on initial entry you can still edit, yet as soon as you click in the subform, you cannot edit in the main form?

    I can only assume corruption unless someone else has a better idea?
    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
    Perfac's Avatar
    Perfac is offline Expert
    Windows 10 Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    Thanks for your help.
    The total different solution is actually so easy I am a little embarrassed.
    In query q01EducationalInstit there is a field the primary key "EduinsID" which is now linked to "Coment_IDb" in query q01Images.
    The code in blue is not needed, so the form result the way it is desired to.

  13. #13
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,914
    Quote Originally Posted by Perfac View Post
    Thanks for your help.
    The total different solution is actually so easy I am a little embarrassed.
    In query q01EducationalInstit there is a field the primary key "EduinsID" which is now linked to "Coment_IDb" in query q01Images.
    The code in blue is not needed, so the form result the way it is desired to.
    That does not explain why it behaves as it does?
    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

  14. #14
    Perfac's Avatar
    Perfac is offline Expert
    Windows 10 Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    Yes, it makes no sense and I didn't learn anything about the issue.

  15. #15
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,651
    Odd.
    I commented out a line of code and I get a .addnew or .update error for no obvious reason.
    I searched the code for it but found no instances.
    Code:
    Private Sub txtEducationalInstitNameZZ_AfterUpdate()
        'Me.txtEducationalInstitNameA = Me.txtEducationalInstitNameZZ
    End Sub
    Why do you format all your fields in the table? It only disguises the true data?
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

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

Similar Threads

  1. I Think I already have part of it
    By Lou_Reed in forum Access
    Replies: 2
    Last Post: 05-07-2017, 11:22 AM
  2. Nullifying a field's contents
    By DubCap01 in forum Access
    Replies: 3
    Last Post: 06-18-2015, 06:48 AM
  3. Part of field matches part of another field
    By fishhead in forum Queries
    Replies: 13
    Last Post: 04-10-2015, 01:54 PM
  4. How Can export Large table part by part
    By shabar in forum Import/Export Data
    Replies: 2
    Last Post: 02-04-2013, 06:29 AM
  5. WHERE as part of JOIN not after
    By thestappa in forum Queries
    Replies: 1
    Last Post: 05-14-2010, 10:52 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