Hi Forum,
I have an unbound form with multiple textbox. I am trying to force users to fill all required field, then INSERT to a table.
Conditions are,
Dim arrAcct As Variant
Dim i As Integer
arrAcct = Split(Me.TxtAccounts, vbCrLf)
If IsNull (Me.Text1) Thenmsgbox "Text1 is empty"Me.Text1.SetFocus
ElseIf IsNull (Me.Text2) Thenmsgbox "Text2 is empty"Me.Text2.SetFocus
ElseIf IsNull (Me.Text3) Thenmsgbox "Text3 is empty"Me.Text3.SetFocus
For i = 0 To UBound(arrAcct)
CurrentDb.Execute "INSERT INTO tblAccounts (TransAccount) VALUES ('" & arrAcct & "')"
Next
End If
But this is giving an error. If all fields are NOT filled out do not Execute INSERT. How can i use IF here properly.
Thank you for your valuable time.