Can some one provide me VBA codes to make the warning dialog box popout?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • accessbeginner
    New Member
    • Apr 2014
    • 4

    #1

    Can some one provide me VBA codes to make the warning dialog box popout?

    Hi,
    Does anyone know how to insert a warning message (make a warning message dialog box displays also) so the user can be aware when he/she selects “CLOSED” from the Status combo box that the form will not be editable once the current is saved/close or if there is a new record is added? (I would like to have a YES and NO button on the dialog box also.)

    The warning message should be like this:

    This form will not be editable after you save, close or add a new record. Do you want to continue?



    Thank you for your help!

    Below are the VBA codes I have used. If you have any other codes better than mine, please feel free to let me know. Thanks


    Code:
    Private Sub Form_AfterUpdate()
    If Me![STATUS] = "CLOSED" Then
        Me.AllowEdits = False
        Else
        Me.AllowEdits = True
    End If
    
    End Sub
    
    
    
    Private Sub Form_Current()
    If Me![STATUS] = "CLOSED" Then
        Me.AllowEdits = False
        Else
        Me.AllowEdits = True
    End If
    
    End Sub
    Last edited by Rabbit; Apr 29 '14, 03:47 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • jimatqsi
    Moderator Top Contributor
    • Oct 2006
    • 1293

    #2
    ab,
    What you want is the MsgBox function. Take a look at it. You'll call it something like this:
    Code:
    if msgbox ("Hey there user, did you know that ...",vbYesNo)=vbYes then ... do stuff
    else
       don't do stuff
    end if

    Comment

    • zmbd
      Recognized Expert Moderator Expert
      • Mar 2012
      • 5501

      #3
      here's the link:
      MsgBox Function (ACC2007 but it hasn't changed since ACC2003)

      Comment

      • accessbeginner
        New Member
        • Apr 2014
        • 4

        #4
        Hi zmbd and jimatqsi,
        I know that I need to have VBA code for this but I am absolutely don't know anything about how to write it and where to insert it. Could you please kindly provide me a VBA code and show me where to insert it?
        Thanks

        Comment

        • zmbd
          Recognized Expert Moderator Expert
          • Mar 2012
          • 5501

          #5
          What I can and will do is PM you a basic set of tutorials and reference links. Please check your Bytes.com Inbox.

          You absolutely must master the first tutorial in this set before you can hope to get anything useful out of Access and benifit from the help we can give you here, or indeed, in any Access website.

          Comment

          Working...