RESOLVED! Can't seem to change thread to resolved so If any admin comes across please change. Thanks
Hello.
I have the following code which I use one my forms to search and bring up a record. It works great. However it requires the user to know the actually unique property reference number to search.
Code:
Private Sub cmdSearchPropref_Click()
Dim Rs As DAO.Recordset
If Not IsNull(Me.cboMoveTo) Then
'Save before move.
If Me.Dirty Then
Me.Dirty = False
End If
'Search in the clone set.
Set Rs = Me.RecordsetClone
Rs.FindFirst "[propref] = """ & Me.cboMoveTo & """"
If Rs.NoMatch Then
MsgBox "Record not found please check number and try again?", vbOKOnly, "Search Error"
Else
'Display the found record in the form.
Me.Bookmark = Rs.Bookmark
End If
Set Rs = Nothing
End If
End Sub
I was wondering if I could use two different fields hsno and address 1 for a search I.e. the user can enter a house number in the textbox search for hsno and then enter address 1 in textbox search for address1. To search any ideas much appreciated.
I thought maybe something like the following but it does not work.
Code:
Private Sub cmdSearchAddress_Click()
Dim Rs As DAO.Recordset
If Not IsNull(Me.cboMoveTo) Then
'Save before move.
If Me.Dirty Then
Me.Dirty = False
End If
'Search in the clone set.
Set Rs = Me.RecordsetClone
Rs.FindFirst "[hsno] = """ And "[address1] = """ & Me.cboMoveTo & """"
If Rs.NoMatch Then
MsgBox "Record not found please Address and try again?", vbOKOnly, "Search Error"
Else
'Display the found record in the form.
Me.Bookmark = Rs.Bookmark
End If
Set Rs = Nothing
End If
End Sub