MsgBox Not Appeared in some situation

basilyos

Registered User.
Local time
Today, 05:26
Joined
Jan 13, 2014
Messages
256
hello guys i want to get a msgbox to let the user enter the data in specific textboxes so they can't let it empty if not empty then do .......

this is my code

If Me.Client_Name.Value = "" Then
MSG = MsgBox("You Should Enter The Client Name")
ElseIf Me.Username.Value = "" Then
MSG = MsgBox("You Should Enter The UserName")
ElseIf Me.Address.Value = "" Then
MSG = MsgBox("You Should Enter The Address")
ElseIf Me.Registered_Date.Value = "" Then
MSG = MsgBox("You Should Enter The Registered Date")
ElseIf Me.Phone_01.Value = "" Then
MSG = MsgBox("You Should Enter At least One Phone Number")
ElseIf Me.Mobile_01.Value = "" Then
MSG = MsgBox("You Should Enter The At least One Mobile Number")
ElseIf Me.cbo_where_to_pay.Value = "" Then
MSG = MsgBox("You Should Enter The Place To Pay")
ElseIf Me.cbo_zone.Value = "" Then
MSG = MsgBox("You Should Enter The Zone Area")
ElseIf Me.Client_Name <> "" And Me.Username.Value <> "" And Me.Address.Value <> "" And Me.Registered_Date.Value <> "" And Me.Phone_01.Value <> "" And Me.Mobile_01 <> "" And Me.cbo_where_to_pay.Value <> "" And Me.cbo_zone <> "" Then
Answer = MsgBox("Adding New Account" & vbCrLf & _
"" & vbCrLf & _
"Client Name : " & [Client_Name] & vbCrLf & _
"" & vbCrLf & _
"UserName : " & [Username] & vbCrLf & _
"" & vbCrLf & _
"Address : " & [Address] & vbCrLf & _
"" & vbCrLf & _
"Registered Date : " & [Registered_Date] & vbCrLf & _
"" & vbCrLf & _
"Phone Number : " & [Phone_01] & " " & [Phone_02] & vbCrLf & _
"" & vbCrLf & _
"Mobile Number : " & [Mobile_01] & " " & [Mobile_02] & vbCrLf & _
"" & vbCrLf & _
"Place To Pay : " & [cbo_where_to_pay].Column(1) & vbCrLf & _
"" & vbCrLf & _
"Zone Area : " & [cbo_zone].Column(1) & vbCrLf & _
"" & vbCrLf & _
"Click Yes If You Want To Proceed With This Information", vbYesNo + vbQuestion + vbDefaultButton1, "ZedNet - Adding New Client")
If Answer = vbYes Then
strsql101 = "insert into tblPersonalInformation (ClientName, Username, Address, Registered_Date, Phone_01, Phone_02, Mobile_01, Mobile_02, Where_To_Pay, Zone, Email) Values ('" & Me.Client_Name & "','" & Me.Username & "','" & Me.Address & "','" & Me.Registered_Date & "','" & Me.Phone_01 & "','" & Me.Phone_02 & "','" & Me.Mobile_01 & "','" & Me.Mobile_02 & "','" & Me.cbo_where_to_pay.Column(1) & "','" & Me.cbo_zone.Column(1) & "','" & Me.Email & "')"
DoCmd.SetWarnings False
DoCmd.RunSQL strsql101
Me.Client_Name = ""
Me.Username = ""
Me.Address = ""
Me.Registered_Date = ""
Me.Phone_01 = ""
Me.Phone_02 = ""
Me.Mobile_01 = ""
Me.Mobile_02 = ""
Me.cbo_where_to_pay = ""
Me.cbo_zone = ""
AccCreated = MsgBox("New Client was Successfully Created", vbOKOnly + vbInformation, "ZedNet - Adding New Client")
End If
End If



the msgboxes that tell the user this textbox is empty is not appearing what's wrong with my code
 
Looks like you have not done a good job of copying and pasting.
Code:
If Len(Me.Client_Name & "") = 0 Then
    MsgBox "You Should Enter The Client Name"
ElseIf Len(Me.Username & "") = 0 Then
    MsgBox "You Should Enter The UserName"
ElseIf Len(Me.Address & "") = 0 Then
    MsgBox "You Should Enter The Address"
ElseIf Len(Me.Registered_Date & "") = 0 Then
    MsgBox "You Should Enter The Registered Date"
ElseIf Len(Me.Email & "") = 0 Then
    MsgBox "You Should Enter The Email"
ElseIf Len(Me.cbo_where_to_pay & "") = 0 Then
    MsgBox "You Should Enter The Place To Pay"
ElseIf Len(Me.cbo_zone & "") = 0 Then
    MsgBox "You Should Enter The Zone Area"
ElseIf Len(Me.Phone_01 & "") = 0 Then
    MsgBox "You should enter a Phone Number"
ElseIf Len(Me.Mobile_01 & "") = 0 Then
    MsgBox "You should enter a Mobile Number"
Else
    Answer = MsgBox("Adding New Account" & vbCrLf & vbCrLf & _
                    "Client Name : " & [Client_Name] & vbCrLf & _
                    "UserName : " & [Username] & vbCrLf & _
                    "Address : " & [Address] & vbCrLf & _
                    "Registered Date : " & [Registered_Date] & vbCrLf & _
                    "Phone Number : " & [Phone_01] & " " & [Phone_02] & vbCrLf & _
                    "Mobile Number : " & [Mobile_01] & " " & [Mobile_02] & vbCrLf & _
                    "Place To Pay : " & [cbo_where_to_pay].Column(1) & vbCrLf & _
                    "Zone Area : " & [cbo_zone].Column(1) & vbCrLf & vbCrLf & _
                    "Click Yes If You Want To Proceed With This Information", vbYesNo + vbQuestion + vbDefaultButton1, "ZedNet - Adding New Client")

    If Answer = vbYes Then
        strsql101 = "insert into tblPersonalInformation (ClientName, Username, Address, Registered_Date, Phone_01, Phone_02, Mobile_01, Mobile_02, Where_To_Pay, Zone, Email) Values ('" & Me.Client_Name & "','" & Me.Username & "','" & Me.Address & "','" & Me.Registered_Date & "','" & Me.Phone_01 & "','" & Me.Phone_02 & "','" & Me.Mobile_01 & "','" & Me.Mobile_02 & "','" & Me.cbo_where_to_pay.Column(1) & "','" & Me.cbo_zone.Column(1) & "','" & Me.Email & "')"
        DoCmd.SetWarnings False
        DoCmd.RunSQL strsql101
        Me.Client_Name = ""
        Me.Username = ""
        Me.Address = ""
        Me.Registered_Date = ""
        Me.Phone_01 = ""
        Me.Phone_02 = ""
        Me.Mobile_01 = ""
        Me.Mobile_02 = ""
        Me.cbo_where_to_pay = ""
        Me.cbo_zone = ""
        MsgBox "New Client was Successfully Created", vbOKOnly + vbInformation, "ZedNet - Adding New Client"
    End If
End If
PS : Please use CODE tags when posting VBA Code.
 
ok Sir thank you so much it works fine
 

Users who are viewing this thread

Back
Top Bottom