Eljefegeneo
Still trying to learn
- Local time
- Yesterday, 20:34
- Joined
- Jan 10, 2011
- Messages
- 902
Input box Search problem
I have been using the following to find a record in my frmMain using an Input Box:
Private Sub cmdClientIdSearch_Click()
'Searches for Client by ID number
Dim rs As Object
Dim strCriteria As String
strCriteria = InputBox("Please enter Client ID" & vbCr & "Do not type leading zeros")
If strCriteria > "" Then
Set rs = Me.RecordsetClone
With rs
.FindFirst "[ClientID] Like '" & Val(strCriteria) & "*'"
If .NoMatch Then
MsgBox "Sorry, no match was found.", vbExclamation, "Not Found"
Else
Me.Bookmark = .Bookmark
End If
End With
Set rs = Nothing
End If
End Sub
It works great if I run it from a command button from frmMain. But, if frmMain is open and I run it from a command button on my switchboard, I get the following error message:
Run Time error 7951. You entered an expression that has an invalid reference to the Recordset Clone Property. I tried inserting a command to open frmMain in the first line, even before the two Dim statements, but I get the same result. Maybe someone could tell me where I am miscoding. Thanks.
I have been using the following to find a record in my frmMain using an Input Box:
Private Sub cmdClientIdSearch_Click()
'Searches for Client by ID number
Dim rs As Object
Dim strCriteria As String
strCriteria = InputBox("Please enter Client ID" & vbCr & "Do not type leading zeros")
If strCriteria > "" Then
Set rs = Me.RecordsetClone
With rs
.FindFirst "[ClientID] Like '" & Val(strCriteria) & "*'"
If .NoMatch Then
MsgBox "Sorry, no match was found.", vbExclamation, "Not Found"
Else
Me.Bookmark = .Bookmark
End If
End With
Set rs = Nothing
End If
End Sub
It works great if I run it from a command button from frmMain. But, if frmMain is open and I run it from a command button on my switchboard, I get the following error message:
Run Time error 7951. You entered an expression that has an invalid reference to the Recordset Clone Property. I tried inserting a command to open frmMain in the first line, even before the two Dim statements, but I get the same result. Maybe someone could tell me where I am miscoding. Thanks.