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

    Message Box

    I am trying to fix my previous challenge in a much more complicated way, but please focus on what I am after here. I respect your time. You only need to have a look at form f01Agent and the code page on the attached DB.


    a. If you select "SARS (Income Tax)" in the Combobox(yellow) Entity Feature, there must be a Message in the message box, "Entity Feature Already Used".
    b. There is a text field on the form f01Agent named txtEntFea1. When the selection is made this text field will return a 1.
    c. Look only at the first paragraph on my code. The message must appear as soon as txtEntFea1 = 1 and XXX = "Once".
    d. I commented it out, but when on it gives an error message.
    e. The only help I need here is for the message to show.

    Thank you.
    Attached Files Attached Files

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    Remove that '=' after msgbox.

    Code:
        If Me.txtEntFea1 = 1 And Me!XXX = "Once" Then
        MsgBox "Entity Feature Already Used"
     End If

  3. #3
    Perfac's Avatar
    Perfac is offline Expert
    Windows 10 Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    Thank you Dave. Look at the image, see the error message.
    Click image for larger version. 

Name:	220719b.png 
Views:	16 
Size:	38.7 KB 
ID:	48352

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    You have not removed the = as suggested?

    Why are you mixing Me. and 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
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    looks to me like Dave has provided the correct solution - but you have not applied it

  6. #6
    Perfac's Avatar
    Perfac is offline Expert
    Windows 10 Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    Thanks all. It works well. My age is catching up, shame.

  7. #7
    xps35's Avatar
    xps35 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jun 2022
    Location
    Schiedam, NL
    Posts
    232
    Quote Originally Posted by Perfac View Post
    Thanks all. It works well.
    I can't imagine it is working well.
    You don't do anything with "me.YYY". That variable says whether the feature is already being used. I think the message box always pops up if the "AppearanceA" is equal to "once".
    And if it appears, you still leave the chosen value.
    You have also adjusted your requirements in the meantime. First (in your other post) you wanted to show where the chosen values ​​were used. Apparently that is no longer necessary.

    Code:
    Private Sub cboEntFea_AfterUpdate()
      Me!XXX = DLookup("AppearanceA", "q01EntityFeatures", "EntfeaID =" & Me.cboEntFea)
      
      If Me.txtEntFea1 = 1 Then
        Me!YYY = DLookup("EntityNameA", "q01CombinedEntities", "Entfea_IDa =" & Me.cboEntFea)
      Else
        Me!YYY = Null
      End If
        
      If Me.txtEntFea1 = 1 And Me!XXX = "Once" Then
        MsgBox "Entity Feature Already Used"
      End If
    End Sub

  8. #8
    Perfac's Avatar
    Perfac is offline Expert
    Windows 10 Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    I thought it is right to use Me. when there is an unbounded field on the form, and Me! when it is bounded.

    About YYY. The name of the entity which currently holds that EntityFeatureID appears in YYY. The message box message should therefore return "Entity Feature Already used by Sars (Income Tax).
    I was kept busy here for a couple of hours, but I will try that now.
    My immediate guess is MsgBox "Entity Feature Already Used by"&""&YYY. What do you think?

  9. #9
    xps35's Avatar
    xps35 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jun 2022
    Location
    Schiedam, NL
    Posts
    232
    The "me" part is not the problem.
    The problem is that in your last IF you do not look at the value of me.YYY. That means that regardless of whether me.YYY is null or not, the message box is displayed (in case of "once").

  10. #10
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    I tend to use Me. until Access complains.
    There is a subtle difference between each, but I always forget the differences.

    See here for an explanation
    https://www.access-programmers.co.uk.../#post-1750807
    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

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

Similar Threads

  1. Replies: 14
    Last Post: 05-31-2020, 10:50 AM
  2. Replies: 3
    Last Post: 05-13-2018, 12:59 AM
  3. Replies: 2
    Last Post: 01-23-2014, 12:40 PM
  4. Replies: 15
    Last Post: 11-01-2013, 03:24 PM
  5. Replies: 9
    Last Post: 09-26-2012, 12:20 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