Message box that will ask you to provide user information if you click save

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jodeny
    New Member
    • Oct 2012
    • 2

    Message box that will ask you to provide user information if you click save

    I'm using this code to either ask for user information if not provided OR save the user info if available BUT when i click on my command button save, i get this message when no info is provided,"New User has been successfully added"

    Code:
    Private Sub cmdSave_Click()
    If UserId = "" Or Password = "" Or UserName = "" Or AuthorityLevel = "" Then
        
        MsgBox "Complete User Information NOT Provided"
        Else
    
    DoCmd.Save
    DoCmd.GoToRecord , , acNewRec
     MsgBox "New User has been successfully added"
    End If
    End sub
    Last edited by Meetee; Oct 3 '12, 05:40 AM. Reason: Always use code tags
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Are you sure the default values are blank strings? Or are they nulls? Usually if no data has ever been entered, the value of the field will be null, not a blank string as you have it.

    Comment

    • Jodeny
      New Member
      • Oct 2012
      • 2

      #3
      The default values are null.

      Comment

      • zmbd
        Recognized Expert Moderator Expert
        • Mar 2012
        • 5501

        #4
        Then per Rabbit, you need to test for Null values as the double quote is not the same.

        Comment

        • TheSmileyCoder
          Recognized Expert Moderator Top Contributor
          • Dec 2009
          • 2322

          #5
          Assuming you have a textbox on your form by the name of tb_Username, there are 2 ways to test it for :
          Code:
          If Me.tb_UserName & ""="" then
          works since Null & "" is equal to ""
          Another way is:
          Code:
          IF Nz(Me.tb_UserName,"")="" then
          The NZ function is used to convert a null value to a safe value, or a default value if you wish.

          Comment

          Working...