M
Maha
From my main form, the user inputs a value to search on
and the form opens with the matching record. The problem
is if there are no records, I'd like a message to pop up
before the form opens (which it does to a new record), so
I can prevent the form from opening at all. The current
code I have seems too inefficient, because it opens the
form, checks to see if it's on a new record, closes it if
it is, then the message pops up. How can I check for
matching records before opening the form? Here's my code:
stDocName = "frmComplaint"
stLinkCriteria = "[complaintID]=" & Me![txtIncidentNum]
DoCmd.OpenForm stDocName, , , stLinkCriteria
If Forms!frmComplaint.NewRecord = True Then
DoCmd.Close
MsgBox ("Incident not found.")
End If
I'd appreciate any ideas/solutions you may have.
TIA!!
and the form opens with the matching record. The problem
is if there are no records, I'd like a message to pop up
before the form opens (which it does to a new record), so
I can prevent the form from opening at all. The current
code I have seems too inefficient, because it opens the
form, checks to see if it's on a new record, closes it if
it is, then the message pops up. How can I check for
matching records before opening the form? Here's my code:
stDocName = "frmComplaint"
stLinkCriteria = "[complaintID]=" & Me![txtIncidentNum]
DoCmd.OpenForm stDocName, , , stLinkCriteria
If Forms!frmComplaint.NewRecord = True Then
DoCmd.Close
MsgBox ("Incident not found.")
End If
I'd appreciate any ideas/solutions you may have.
TIA!!