When you are checking to see if the IsNull(lstIncident) What property is it testing for? It looks like it is checking for a record because you either call an Insert INTO or an Update for the SQL statement.
Thank you.
Code:
If IsNull(lstIncident) Then MsgBox "ERROR: An incident must be chosen before adding or updating exposures present", vbOKOnly, "ERROR Adding/Updating Exposure"
Else
RequiredCheck = SubRequired(Me.Name, Screen.ActiveControl.Tag, Forms(Me.Name).Controls(Replace(Me.Name, "frm", "tab")).Pages(Forms(Me.Name).Controls(Replace(Me.Name, "frm", "tab"))).Name)
If Len(RequiredCheck) > 0 Then
MsgBox "The following fields are required to add an exposure" & vbCrLf & vbCrLf & RequiredCheck, vbOKOnly, "ERROR ADDING/UPDATING EXPOSURE"
Else
If IsNull(lstIncidentExposure) Then
If DCount("*", "tblIncidentExposure", "[IncidentID] = " & lstIncident & " AND [Exp_ID] = " & Exp_ID) > 0 Then
MsgBox "That exposure already exists on this incident", vbOKOnly, "ERROR ADDING EXPOSURE"
Else
Call SubAdd(Me.Name, Screen.ActiveControl.Tag, Forms(Me.Name).Controls(Replace(Me.Name, "frm", "tab")).Pages(Forms(Me.Name).Controls(Replace(Me.Name, "frm", "tab"))).Name)
Call SubClear(Me.Name, Screen.ActiveControl.Tag, Forms(Me.Name).Controls(Replace(Me.Name, "frm", "tab")).Pages(Forms(Me.Name).Controls(Replace(Me.Name, "frm", "tab"))).Name)
End If
Else
If DCount("*", "tblIncidentExposure", "[IncidentID] = " & lstIncident & " AND [Exp_ID] = " & Exp_ID & " AND [IncExp_ID] <> " & lstIncidentExposure) > 0 Then
MsgBox "That exposure already exists on this incident", vbOKOnly, "ERROR UPDATING EXPOSURE"
Else
Call SubUpdate(Me.Name, Screen.ActiveControl.Tag, Forms(Me.Name).Controls(Replace(Me.Name, "frm", "tab")).Pages(Forms(Me.Name).Controls(Replace(Me.Name, "frm", "tab"))).Name)
Call SubClear(Me.Name, Screen.ActiveControl.Tag, Forms(Me.Name).Controls(Replace(Me.Name, "frm", "tab")).Pages(Forms(Me.Name).Controls(Replace(Me.Name, "frm", "tab"))).Name)
End If
End If
End If
End If
End Sub
I understand what the below sub procedure is doing, but I don't quite understand how it knows to insert into a different table. It looks like you are passing the values to:
Code:
Private Sub cmdSub1Add_Click()..........
Call SubAdd(Me.Name, Screen.ActiveControl.Tag, Forms(Me.Name).Controls(Replace(Me.Name, "frm", "tab")).Pages(Forms(Me.Name).Controls(Replace(Me.Name, "frm", "tab"))).Name)
Function SubAdd(sFormname, sSub, sTab)
then checking the tags...
If InStr(ctl.Tag, sSub) Then
But, then I get a little lost.
Thanks!