beanbeanbean
Registered User.
- Local time
- Yesterday, 16:07
- Joined
- Sep 17, 2008
- Messages
- 124
hi can anyone help me with the validation.
i'm having trouble with the codes.
i am creating an insert form which inserts data into the datasheet. Thats where the problem comes. it only allows me to proceed if all the fields have something in them. anyone knows how to allow the process to continue even if some fields are left blank ?
Also can u guys help me and tell me what error is this ?
" Invalid SQL statement; expected 'DELETE', 'INSERT', "PROCEDURE', 'SELECT', or 'UPDATE'. "
It happens everytime when i try to enter the data without filling in all the fields. After that comes out, then only will my msg box appear. Why is that so ?
Thanks for the help in advance. I am really grateful.
I've attached the code i have for reference.
Private Sub Command29_Click()
'------------------------------------------
If (Text88.Value) = "" Then
MsgBox "Please enter Lan ID"
ElseIf Text106.Value = "" Then
MsgBox ("Please enter Status")
ElseIf Text90.Value = "" Then
MsgBox ("Please enter Staff ID")
ElseIf Text94.Value = "" Then
MsgBox ("Please enter Franchise")
ElseIf Text92.Value = "" Then
MsgBox ("Please enter Querier's Email Address")
ElseIf Text96.Value = "" Then
MsgBox ("Please enter Channel Received")
ElseIf Text98.Value = "" Then
MsgBox ("Please enter Product 1")
ElseIf Text104.Value = "" Then
MsgBox ("Please enter Customer IC 1")
ElseIf Text112.Value = "" Then
MsgBox ("Please enter Dollar Amount 1")
ElseIf Text118.Value = "" Then
MsgBox ("Please enter Transaction Date 1")
ElseIf Text124.Value = "" Then
MsgBox ("Please enter Date of Query")
ElseIf Text126.Value = "" Then
MsgBox ("Please enter Discrepancy")
ElseIf Text128.Value = "" Then
MsgBox ("Please enter Request")
ElseIf Text130.Value = "" Then
MsgBox ("Please enter Staff's Email Address")
End If
'----------------------------------------
'------------------------------------------
If IsNull(Text88.Value) Then
Text88.Value = ""
ElseIf IsNull(Text106.Value) Then
Text106.Value = ""
ElseIf IsNull(Text90.Value) Then
Text90.Value = ""
ElseIf IsNull(Text92.Value) Then
Text92.Value = ""
ElseIf IsNull(Text94.Value) Then
Text94.Value = ""
ElseIf IsNull(Text96.Value) Then
Text96.Value = ""
ElseIf IsNull(Text98.Value) Then
Text98.Value = ""
ElseIf IsNull(Text104.Value) Then
Text104.Value = ""
ElseIf IsNull(Text112.Value) Then
Text112.Value = ""
ElseIf IsNull(Text118.Value) Then
Text118.Value = ""
ElseIf IsNull(Text126.Value) Then
Text126.Value = ""
ElseIf IsNull(Text128.Value) Then
Text128.Value = ""
ElseIf IsNull(Text124.Value) Then
Text124.Value = ""
ElseIf IsNull(Text130.Value) Then
Text130.Value = ""
ElseIf IsNull(Text100.Value) Then
Text100.Value = ""
ElseIf IsNull(Text102.Value) Then
Text102.Value = ""
ElseIf IsNull(Text108.Value) Then
Text108.Value = ""
ElseIf IsNull(Text110.Value) Then
Text110.Value = ""
ElseIf IsNull(Text114.Value) Then
Text114.Value = ""
ElseIf IsNull(Text116.Value) Then
Text116.Value = ""
ElseIf IsNull(Text120.Value) Then
Text120.Value = ""
ElseIf IsNull(Text122.Value) Then
Text122.Value = ""
End If
'-----------------------------------------------
Dim sqlString As String
On Error GoTo Err_Topic_NotInList
DoCmd.RunSQL "Insert Into [Query Database] ([Status],[Lan ID],[Staff ID],[Querier Email Address],[Franchise],[Channel Received],[Product 1],[Product 2],[Product 3],[Customer IC 1],[Customer IC 2],[Customer IC 3],[Dollar Amount 1],[Dollar Amount 2],[Dollar Amount 3],[Transaction Date 1],[Transaction Date 2],[Transaction Date 3],[Discrepancy],[Request],[Date of Query],[Staff Email Address])Values ('" + Text106.Value + "','" + Text88.Value + "','" + Text90.Value + "','" + Text92.Value + "','" + Text94.Value + "','" + Text96.Value + "','" + Text98.Value + "','" + Text100.Value + "','" + Text102.Value + "','" + Text104.Value + "','" + Text108.Value + "','" + Text110.Value + "','" + Text112.Value + "', '" + Text114.Value + "', '" + Text116.Value + "', '" + Text118.Value + "', '" + Text120 + "', '" + Text122 + "', '" + Text126 + "', '" + Text128 + "', '" + Text124 + "', '" + Text130 + "')"
'-----------------------------------------------
'------------------AUDIT LOG-----------------------------------------------------------------------------------------
Open "C:\Documents and Settings\johnteo\Desktop\Audit Log.txt" For Append As #1
Write #1, "-------------------------------------------------------------------------------------"
Write #1, "A new file : " & Text88.Value & " has been inserted on " & Format(Now(), "m/d/yy h:m:s AMPM") & ""
Write #1,
Close #1
Exit Sub
'Else: Exit Sub
'-----------------------------------------------
Err_Topic_NotInList:
' An unexpected error occurred,
' display the normal error message.
MsgBox Err.Description
' Set the Response argument to suppress
' an error message and undo changes.
Response = acDataErrContinue
Exit Sub
'db.Execute (sqlString)
'sqlString = "Insert Into [Simple_Check] ( ,,)Values ('" + Pot_Owner_Text.Value + "','" + New_Pot_Owner_Text.Value + "','" + Problematic_text.Value + "',,,)"
'db.Execute (sqlString)
'End If
End Sub
i'm having trouble with the codes.
i am creating an insert form which inserts data into the datasheet. Thats where the problem comes. it only allows me to proceed if all the fields have something in them. anyone knows how to allow the process to continue even if some fields are left blank ?
Also can u guys help me and tell me what error is this ?
" Invalid SQL statement; expected 'DELETE', 'INSERT', "PROCEDURE', 'SELECT', or 'UPDATE'. "
It happens everytime when i try to enter the data without filling in all the fields. After that comes out, then only will my msg box appear. Why is that so ?
Thanks for the help in advance. I am really grateful.
I've attached the code i have for reference.
Private Sub Command29_Click()
'------------------------------------------
If (Text88.Value) = "" Then
MsgBox "Please enter Lan ID"
ElseIf Text106.Value = "" Then
MsgBox ("Please enter Status")
ElseIf Text90.Value = "" Then
MsgBox ("Please enter Staff ID")
ElseIf Text94.Value = "" Then
MsgBox ("Please enter Franchise")
ElseIf Text92.Value = "" Then
MsgBox ("Please enter Querier's Email Address")
ElseIf Text96.Value = "" Then
MsgBox ("Please enter Channel Received")
ElseIf Text98.Value = "" Then
MsgBox ("Please enter Product 1")
ElseIf Text104.Value = "" Then
MsgBox ("Please enter Customer IC 1")
ElseIf Text112.Value = "" Then
MsgBox ("Please enter Dollar Amount 1")
ElseIf Text118.Value = "" Then
MsgBox ("Please enter Transaction Date 1")
ElseIf Text124.Value = "" Then
MsgBox ("Please enter Date of Query")
ElseIf Text126.Value = "" Then
MsgBox ("Please enter Discrepancy")
ElseIf Text128.Value = "" Then
MsgBox ("Please enter Request")
ElseIf Text130.Value = "" Then
MsgBox ("Please enter Staff's Email Address")
End If
'----------------------------------------
'------------------------------------------
If IsNull(Text88.Value) Then
Text88.Value = ""
ElseIf IsNull(Text106.Value) Then
Text106.Value = ""
ElseIf IsNull(Text90.Value) Then
Text90.Value = ""
ElseIf IsNull(Text92.Value) Then
Text92.Value = ""
ElseIf IsNull(Text94.Value) Then
Text94.Value = ""
ElseIf IsNull(Text96.Value) Then
Text96.Value = ""
ElseIf IsNull(Text98.Value) Then
Text98.Value = ""
ElseIf IsNull(Text104.Value) Then
Text104.Value = ""
ElseIf IsNull(Text112.Value) Then
Text112.Value = ""
ElseIf IsNull(Text118.Value) Then
Text118.Value = ""
ElseIf IsNull(Text126.Value) Then
Text126.Value = ""
ElseIf IsNull(Text128.Value) Then
Text128.Value = ""
ElseIf IsNull(Text124.Value) Then
Text124.Value = ""
ElseIf IsNull(Text130.Value) Then
Text130.Value = ""
ElseIf IsNull(Text100.Value) Then
Text100.Value = ""
ElseIf IsNull(Text102.Value) Then
Text102.Value = ""
ElseIf IsNull(Text108.Value) Then
Text108.Value = ""
ElseIf IsNull(Text110.Value) Then
Text110.Value = ""
ElseIf IsNull(Text114.Value) Then
Text114.Value = ""
ElseIf IsNull(Text116.Value) Then
Text116.Value = ""
ElseIf IsNull(Text120.Value) Then
Text120.Value = ""
ElseIf IsNull(Text122.Value) Then
Text122.Value = ""
End If
'-----------------------------------------------
Dim sqlString As String
On Error GoTo Err_Topic_NotInList
DoCmd.RunSQL "Insert Into [Query Database] ([Status],[Lan ID],[Staff ID],[Querier Email Address],[Franchise],[Channel Received],[Product 1],[Product 2],[Product 3],[Customer IC 1],[Customer IC 2],[Customer IC 3],[Dollar Amount 1],[Dollar Amount 2],[Dollar Amount 3],[Transaction Date 1],[Transaction Date 2],[Transaction Date 3],[Discrepancy],[Request],[Date of Query],[Staff Email Address])Values ('" + Text106.Value + "','" + Text88.Value + "','" + Text90.Value + "','" + Text92.Value + "','" + Text94.Value + "','" + Text96.Value + "','" + Text98.Value + "','" + Text100.Value + "','" + Text102.Value + "','" + Text104.Value + "','" + Text108.Value + "','" + Text110.Value + "','" + Text112.Value + "', '" + Text114.Value + "', '" + Text116.Value + "', '" + Text118.Value + "', '" + Text120 + "', '" + Text122 + "', '" + Text126 + "', '" + Text128 + "', '" + Text124 + "', '" + Text130 + "')"
'-----------------------------------------------
'------------------AUDIT LOG-----------------------------------------------------------------------------------------
Open "C:\Documents and Settings\johnteo\Desktop\Audit Log.txt" For Append As #1
Write #1, "-------------------------------------------------------------------------------------"
Write #1, "A new file : " & Text88.Value & " has been inserted on " & Format(Now(), "m/d/yy h:m:s AMPM") & ""
Write #1,
Close #1
Exit Sub
'Else: Exit Sub
'-----------------------------------------------
Err_Topic_NotInList:
' An unexpected error occurred,
' display the normal error message.
MsgBox Err.Description
' Set the Response argument to suppress
' an error message and undo changes.
Response = acDataErrContinue
Exit Sub
'db.Execute (sqlString)
'sqlString = "Insert Into [Simple_Check] ( ,,)Values ('" + Pot_Owner_Text.Value + "','" + New_Pot_Owner_Text.Value + "','" + Problematic_text.Value + "',,,)"
'db.Execute (sqlString)
'End If
End Sub