G
Guest
Hi,
It seems that an "IF" loop is not working in VBA Open procedure.
This is what I'm trying to do:
I'm opening a form named "AuditRecords" from another form. To open it, I also use a combobox with a list of audit names. Everything is fine as long as I choose an audit name in the combobox (named "Audit") before opening "AuditRecords" form. If I dont choose anything, I get of course a blank page (blank "AuditRecords" form, without anything on it, no texts, no fields, no records etc.). So far, nothing wrong.
To remedy the blank page, I added an "If" loop in the open form procedure (called History_Click) in order to not open the form "AuditRecords" if the content of the combobox ([Audit]) is null.
But it does not work.
Below is the code I use. Any help would be greatly apprciated. I dont see what I am missing here:
Private Sub History_Click()
On Error GoTo Err_History_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "AuditRecords"
stLinkCriteria = "[Audit]=" & "'" & Me![Audit] & "'"
If Forms![Menu]![Audit] Is Nothing Then
GoTo Err_History_Click2
End If
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_History_Click:
Exit Sub
Err_History_Click:
MsgBox Err.Description
Resume Exit_History_Click
Err_History_Click2:
MsgBox "Please Select an Audit from the Box."
GoTo Exit_History_Click
End Sub
It seems that an "IF" loop is not working in VBA Open procedure.
This is what I'm trying to do:
I'm opening a form named "AuditRecords" from another form. To open it, I also use a combobox with a list of audit names. Everything is fine as long as I choose an audit name in the combobox (named "Audit") before opening "AuditRecords" form. If I dont choose anything, I get of course a blank page (blank "AuditRecords" form, without anything on it, no texts, no fields, no records etc.). So far, nothing wrong.
To remedy the blank page, I added an "If" loop in the open form procedure (called History_Click) in order to not open the form "AuditRecords" if the content of the combobox ([Audit]) is null.
But it does not work.
Below is the code I use. Any help would be greatly apprciated. I dont see what I am missing here:
Private Sub History_Click()
On Error GoTo Err_History_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "AuditRecords"
stLinkCriteria = "[Audit]=" & "'" & Me![Audit] & "'"
If Forms![Menu]![Audit] Is Nothing Then
GoTo Err_History_Click2
End If
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_History_Click:
Exit Sub
Err_History_Click:
MsgBox Err.Description
Resume Exit_History_Click
Err_History_Click2:
MsgBox "Please Select an Audit from the Box."
GoTo Exit_History_Click
End Sub