Results 1 to 11 of 11
  1. #1
    Ismail vkt is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2020
    Posts
    5

    Message box caption customization.

    Yes! my code given below is working well. What I want is to replace my own title for message box instead of MS Office Access default caption. Means, I need a slight modification on this underlined message code only which I am not able to do. the image attached here is the message receives now.

    Click image for larger version. 

Name:	Msg0.jpg 
Views:	61 
Size:	19.4 KB 
ID:	43079

    If Found_in_filedno > 0 Then MsgBox ("One or more Versus " & X(i - 1) & " found repeated, please Remove it")

    Private Sub AUID_AfterUpdate()



    Debug.Print AUID
    X = Split(AUID, ", ")
    Xsize = UBound(X, 1) - LBound(X, 1) + 1
    For i = 1 To Xsize
    Debug.Print X(i - 1)
    Found_in_filedno = DLookup("[AUID]", "QIndexTbl", "instr([AUID], '" & X(i - 1) & "')>0")
    If Found_in_filedno > 0 Then MsgBox ("One or more Versus " & X(i - 1) & " found repeated, please Remove it")
    Next
    End Sub

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    msgbox "center msg",icon, "Title Caption"
    or
    msgbox "center msg",, "Title Caption"

  3. #3
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    There are a couple of issues with your code.
    1st Issue: I am positive you do not have
    Code:
    Option Compare Databaset    '<<---- These two lines should be at the top of EVERY module
    Option Explicit             '<<---- These two lines should be at the top of EVERY module
    since you do not have your variables declared.

    2nd Issue: You do not have your variables declared.


    I guessed at some of the variable types - since you did not provide examples of the data, I had to guess.
    Here is the modified code. It is untested, but it should work.
    Code:
    Option Compare Databaset    '<<---- These two lines should be at the top of EVERY module
    Option Explicit             '<<---- These two lines should be at the top of EVERY module
    
    
    Private Sub AUID_AfterUpdate()
        Dim X As String
        Dim Xsize As Integer
        Dim i As Integer
        Dim Found_in_filedno As Long
    
        'msgbox variables
        Dim Title As String
        Dim Msg As String
        Dim Style As Long
        Dim Response As Integer
    
    
        '    Debug.Print Me.AUID
        X = Split(Me.AUID, ", ")
        Xsize = UBound(X, 1) - LBound(X, 1) + 1
        For i = 1 To Xsize
            Debug.Print X(i - 1)
            Found_in_filedno = DLookup("[AUID]", "QIndexTbl", "instr([AUID], '" & X(i - 1) & "')>0")
            If Found_in_filedno > 0 Then
                '            MsgBox ("One or more Versus " & X(i - 1) & " found repeated, please Remove it")
                Msg = "One or more Versus " & X(i - 1) & " found repeated, please Remove it"    ' Define message.
                Style = vbOKOnly   ' Define buttons.
                Title = "AUID Error!!"    ' Define title.
              
                Response = MsgBox(Msg, Style, Title)   ' Display message.
            Next
        End Sub
    Change the RED text in the code above to the Title you want.


    And Welcome to the forum........

  4. #4
    Ismail vkt is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2020
    Posts
    5

    Msg Box customization: The sent code is not working !!! Reply see below in blue text.

    [QUOTE=ssanfu;463227]There are a couple of issues with your code.
    1st Issue: I am positive you do not have
    Code:
    Option Compare Databaset    '<<---- These two lines should be at the top of EVERY module
    Option Explicit             '<<---- These two lines should be at the top of EVERY module
    since you do not have your variables declared.

    2nd Issue: You do not have your variables declared.


    I guessed at some of the variable types - since you did not provide examples of the data, I had to guess.
    Here is the modified code. It is untested, but it should work.
    Code:
    Option Compare Databaset    '<<---- These two lines should be at the top of EVERY module
    Option Explicit             '<<---- These two lines should be at the top of EVERY module
    
    
    Private Sub AUID_AfterUpdate()
        Dim X As String
        Dim Xsize As Integer
        Dim i As Integer
        Dim Found_in_filedno As Long
    
        'msgbox variables
        Dim Title As String
        Dim Msg As String
        Dim Style As Long
        Dim Response As Integer
    
    
        '    Debug.Print Me.AUID
        X = Split(Me.AUID, ", ")
        Xsize = UBound(X, 1) - LBound(X, 1) + 1
        For i = 1 To Xsize
            Debug.Print X(i - 1)
            Found_in_filedno = DLookup("[AUID]", "QIndexTbl", "instr([AUID], '" & X(i - 1) & "')>0")
            If Found_in_filedno > 0 Then
                '            MsgBox ("One or more Versus " & X(i - 1) & " found repeated, please Remove it")
                Msg = "One or more Versus " & X(i - 1) & " found repeated, please Remove it"    ' Define message.
                Style = vbOKOnly   ' Define buttons.
                Title = "AUID Error!!"    ' Define title.
              
                Response = MsgBox(Msg, Style, Title)   ' Display message.
            Next
        End Sub
    Change the RED text in the code above to the Title you want.
    ************************************************** *************************************XX

    Dear Brother
    first of all thanking you for responding my question. may god bless you.
    Brother. However my code is working fine. i want the 'title' only, for the message.

    now the code you sent is begun to show different errors. I saved, Option Explicit at the top of my form's module. Option Compare Database already there. this also
    shows error.
    this is Quran Index database for myself. this code for me to avoid duplicate versus in the field. example of data: 001:001, 101:125, if I am trying to save
    101:125, again it should show the versus number through message.
    the field 'AUID' is text.

    if you want my db I can send that particular form.

    Thanking you brother.


  5. #5
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Quote Originally Posted by Ismail vkt View Post
    i want the 'title' only, for the message
    You cannot JUST change the title of the dialog box. You must use the message box function. (see HELP)

    Did you set a break point, then single step through the subroutine? At what line did the error occur?

    It would help if you would post your dB.

  6. #6
    Ismail vkt is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2020
    Posts
    5

    Thumbs up Dear brother, yes it is not functioning.

    Yes as you mentioned it is not functioning.
    I hesitate to give trouble to you. that's why I told it was working. sorry..

    I am sending my DB.
    I have written all the details in a form inside the database.

    attaching db not easy.


    Thanks
    Attached Files Attached Files

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,899
    Code modules should have Option Explicit in header. Review http://www.fmsinc.com/MicrosoftAcces...ons/index.html

    Are you saying a verse number such as 001:001 cannot be in multiple records?

    AUID is holding a comma-separated string. This is probably root of problem. Allowing users to directly edit this string makes it virtually impossible to prevent duplicate verses in records.

    What is purpose of AUID combobox that uses data from same field it is bound to as RowSource? Selecting value from list changes value in existing record.

    Since AUID is a text field testing for DLookup returning 0 makes no sense.

    Misspelling: Versus should be Verses.
    Last edited by June7; 10-04-2020 at 12:27 PM.
    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.

  8. #8
    Ismail vkt is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2020
    Posts
    5

    Msg Box customization. Title for Msg box still not solved.

    Dear brother. Yes a verse number such as 001:001 cannot be in multiple records, ... exactly.
    I don't know but my existing code is doing the work perfectly. it checks every verses between two commas (,).
    regarding AUID combobox, this is for viewing existing data and to take copy of the same and enter after modification.

    My existing code I saved under one button (Update button in DB) no any other addition to library or Option explicit etc.
    After assigning a separate update button Debug message pop up also stopped. means no problem in finding duplicate data except "TITLE'.
    Now only problem is Msg title.

    -----------------------------------------------------------
    This is my existing code.

    Debug.Print AUID
    X = Split(AUID, ", ")
    Xsize = UBound(X, 1) - LBound(X, 1) + 1
    For i = 1 To Xsize
    Debug.Print X(i - 1)
    Found_in_filedno = DLookup("[AUID]", "QIndexTbl", "instr([AUID], '" & X(i - 1) & "')>0")
    If Found_in_filedno > 0 Then MsgBox ("One or more Ayat " & X(i - 1) & " found repeated, please Remove it")
    Next
    -----------------------------------------------------------

    Thanking you, giving prompt reply.



  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,899
    Don't understand issue. If you want custom title then use the Title argument:
    Code:
    If Found_in_filedno > 0 Then MsgBox "One or more Verses " & X(i - 1) & " found repeated, please Remove it", , "Your Title Here"
    
    Might want to change Found_in_filedno to Found_in_fieldno

    I see now that edit of AUID on existing record is not permitted.

    If you want to avoid action query warnings to user, either run action SQL statements in VBA with CurrentDb.Execute or use SetWarnings = False and SetWarnings = True in macro.

    Now I see how the DLookup() is working. When there is no match, DLookup returns Null. So Null > 0 returns Null which is not True. Better condition would be: If Not IsNull(Found_in_filedno) Then.

    Those MouseMove events are annoying me. Accidentally pass over button to close and boom! form closes.
    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.

  10. #10
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    First, my apologies. I did not understand what you wanted.

    It would have been much easier is your design was normalized.
    Adding "Option Explicit" will require all variables in the code to be declared. ("Option Compare Databaset" was wrong. The "t" should not have been there)
    Also, following code is easier if controls have better names than "Combo145". (The "Find Index Record by ID" combo box.)


    As June7 said, all you need to do is use the TITLE argument of the message box function:
    Code:
    Private Sub AUID_AfterUpdate()
    
        Debug.Print AUID
        X = Split(AUID, ", ")
        Xsize = UBound(X, 1) - LBound(X, 1) + 1
        For i = 1 To Xsize
            Debug.Print X(i - 1)
            Found_in_filedno = DLookup("[AUID]", "QIndexTbl", "instr([AUID], '" & X(i - 1) & "')>0")
            If Found_in_filedno > 0 Then MsgBox ("One or more Versus " & X(i - 1) & " found repeated, please Remove it"), , "Duplicate verse number"
        Next
    
        Command91.Enabled = True
    
    
    End Sub
    Change the BLUE text to your title.



    Good luck with your project..

  11. #11
    Ismail vkt is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2020
    Posts
    5
    THANK YOU SIR.
    SOLVED.
    This was I requested.
    how simple it is.
    now i can customize title.
    very good.

    working fine fine.

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

Similar Threads

  1. Replies: 3
    Last Post: 06-30-2020, 12:35 PM
  2. Replies: 15
    Last Post: 11-03-2015, 12:48 AM
  3. Replies: 2
    Last Post: 01-07-2014, 12:18 PM
  4. Getting Value as label Caption
    By Naveen Marapaka in forum Forms
    Replies: 4
    Last Post: 09-18-2013, 12:22 AM
  5. Create Sort Order Customization Thingy
    By Carouser in forum Access
    Replies: 5
    Last Post: 09-04-2012, 12:38 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