I have some code attached to a command button (shown below) that is supposed to check a form to see whether a number of fields are filled in before executing code to link a child field and open a the child table.
For some reason it only ever completes the first if for journalists field checking, when you then fill in the journalist field, the next time you click the command button it executes the code to link the tables even though the other conditions aren't true.
Not sure where I'm going wrong, any help would be greatly appreciated. THANKS
Private Sub Command100_Click()
On Error GoTo Err_Command100_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim inCovID As Integer
If IsNull(Me!cmboJournalist) Or Me!cmboJournalist = "" Then
MsgBox prompt:="Please Select a JOURNALIST!", buttons:=vbOKOnly, Title:="Integrity ERROR"
Exit Sub
ElseIf IsNull(Me!cmboProductSelect) Or Me!cmboProductSelect = "" Then
MsgBox prompt:="Please Select a PRODUCT!", buttons:=vbOKOnly, Title:="Integrity ERROR"
Exit Sub
ElseIf IsNull(Me!cmboCoverageType) Or cmboCoverageType = "" Then
MsgBox prompt:="Please select COVERAGE TYPE!", buttons:=vbOKOnly, Title:="Integrity ERROR"
Exit Sub
ElseIf Me!cmboCoverageType = "1" Then
MsgBox prompt:="You can't send a sample for News Coverage, enter a separate REVIEW field!", buttons:=vbOKOnly, Title:="Integrity ERROR"
Exit Sub
ElseIf IsNull(Me!txtChildLink) Or Me!txtChildLink = "" Then
inCovID = Me![txtCoverageID]
Me!txtChildLink = inCovID
Me.Requery
stLinkCriteria = "[tbl_Coverage_ID]=" & inCovID
stDocName = "SAMPLE_TRANSACTION"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
stLinkCriteria = "[tbl_Coverage_ID]=" & Me![txtCoverageID]
stDocName = "SAMPLE_TRANSACTION"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
Exit_Command100_Click:
Exit Sub
Err_Command100_Click:
'MsgBox Err.Description
Resume Exit_Command100_Click
End Sub
For some reason it only ever completes the first if for journalists field checking, when you then fill in the journalist field, the next time you click the command button it executes the code to link the tables even though the other conditions aren't true.
Not sure where I'm going wrong, any help would be greatly appreciated. THANKS
Private Sub Command100_Click()
On Error GoTo Err_Command100_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim inCovID As Integer
If IsNull(Me!cmboJournalist) Or Me!cmboJournalist = "" Then
MsgBox prompt:="Please Select a JOURNALIST!", buttons:=vbOKOnly, Title:="Integrity ERROR"
Exit Sub
ElseIf IsNull(Me!cmboProductSelect) Or Me!cmboProductSelect = "" Then
MsgBox prompt:="Please Select a PRODUCT!", buttons:=vbOKOnly, Title:="Integrity ERROR"
Exit Sub
ElseIf IsNull(Me!cmboCoverageType) Or cmboCoverageType = "" Then
MsgBox prompt:="Please select COVERAGE TYPE!", buttons:=vbOKOnly, Title:="Integrity ERROR"
Exit Sub
ElseIf Me!cmboCoverageType = "1" Then
MsgBox prompt:="You can't send a sample for News Coverage, enter a separate REVIEW field!", buttons:=vbOKOnly, Title:="Integrity ERROR"
Exit Sub
ElseIf IsNull(Me!txtChildLink) Or Me!txtChildLink = "" Then
inCovID = Me![txtCoverageID]
Me!txtChildLink = inCovID
Me.Requery
stLinkCriteria = "[tbl_Coverage_ID]=" & inCovID
stDocName = "SAMPLE_TRANSACTION"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
stLinkCriteria = "[tbl_Coverage_ID]=" & Me![txtCoverageID]
stDocName = "SAMPLE_TRANSACTION"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
Exit_Command100_Click:
Exit Sub
Err_Command100_Click:
'MsgBox Err.Description
Resume Exit_Command100_Click
End Sub