kentwoodjean
Technical User
I would like to write code that would advide the user that the recordset is empty. The following code appears when the user opens my form that is built upon a member ship table (over 1000 members):
Private Sub ContractNum_Enter()
Private Sub Form_Open(Cancel As Integer)
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "No matches. Try again."
Cancel = True
End If
End Sub
My user will input a number in the field 'Contract Number" which contains an unbound text box and after update property and as a result will populate all other fields on the form pertenent to that particular member. The event property for this is:
Private Sub ContractNum_AfterUpdate()
Dim szSQL As String
szSQL = "select * from qryMembership where Contract_Num = '" & Trim(Me.ContractNum) & "';"
Me.RecordSource = szSQL
End Sub
What I want to happen is to have a message come up indicating there is no record when the user enters a Contract number that is not on the list. I though the form "On Open" would take care of this but does not.
When I first posed this question in another forum, it was suggested that I come to the "Forms" forum.
Thanks.
Private Sub ContractNum_Enter()
Private Sub Form_Open(Cancel As Integer)
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "No matches. Try again."
Cancel = True
End If
End Sub
My user will input a number in the field 'Contract Number" which contains an unbound text box and after update property and as a result will populate all other fields on the form pertenent to that particular member. The event property for this is:
Private Sub ContractNum_AfterUpdate()
Dim szSQL As String
szSQL = "select * from qryMembership where Contract_Num = '" & Trim(Me.ContractNum) & "';"
Me.RecordSource = szSQL
End Sub
What I want to happen is to have a message come up indicating there is no record when the user enters a Contract number that is not on the list. I though the form "On Open" would take care of this but does not.
When I first posed this question in another forum, it was suggested that I come to the "Forms" forum.
Thanks.