icemonster
Registered User.
- Local time
- Today, 13:55
- Joined
- Jan 30, 2010
- Messages
- 502
so i got this code off a site, it's neat cause it loops through the form.
but how do i add in the else statement so that it won't loop? because basically what's happening is for each field in the form is the insert being run. any ideas?
but how do i add in the else statement so that it won't loop? because basically what's happening is for each field in the form is the insert being run. any ideas?
Code:
NotFilledIn = False
For Each ctrl In Me
If InStr(ctrl.Tag, "Required") Then
If IsNull(ctrl) Then 'first if
NotFilledIn = True
ctrl.BackColor = 10092543 'Yellow
ctrl.BorderColor = 13311 'red
Else 'first if
If IsNull(Me.txtemployerid) Then 'second if
If Not IsNull(Me.txtemployer) And Not IsNull(Me.txtjobtitle) And Not IsNull(Me.dtlastdayconv) And Not IsNull(Me.dtstartedconv) Then
strSQL = "INSERT INTO tbl_employer " & _
"(employer_name, employer_jobtitle, employer_startdate, employer_lastday, employer_createdon) VALUES ('" & Me.txtemployer & "', '" & Me.txtjobtitle & "', " _
& "'" & Me.dtstartedconv & "', '" & Me.dtlastdayconv & "', Now());"
.Execute strSQL, , adCmdText + adExecuteNoRecords
strSQL = "SELECT Last_Insert_ID();"
With .Execute(strSQL, , adCmdText)
If Not (.BOF And .EOF) Then
' Found the new ID - build the second Insert SQL string
lngLastEmployerID = .Fields(0)
Else
' Abort
End If
.Close
End With
End If
Else 'second if
End If 'second if
End If 'first if
End If
Next ctrl