Hi, I have this code that works and tells me lets me know if a number exists in a field. So txtFindNumber say 1234.001
exists in the field 'fldNumber' - but I need to bookmark the once its found so the user can edit it - how would I do this please?
Ive had a look at the doc.microsoft page and it suggests I need a 'with rs... end with' - but a bit confused how to use this.
This is my code below
Private Sub cmdFindNumber_Click()
Dim myval As Double
myval = Me!txtFindNumber
Dim rs As DAO.Recordset
Dim my_value As Variant
Dim SQL As String
Set rs = CurrentDb.OpenRecordset( _
"SELECT fldNumber FROM tbl_Data_LOI_Instructions WHERE fldNumber = " & myval & "", dbOpenSnapshot, dbReadOnly)
With Me.RecordsetClone
Do Until rs.EOF
If myval = rs![fldNumber] Then
MsgBox "Number Found", vbOKOnly
Exit Sub
End If
rs.MoveNext
Loop
MsgBox "Number Not Found", vbOKOnly
rs.Close
Set rs = Nothing
End With
End Sub
exists in the field 'fldNumber' - but I need to bookmark the once its found so the user can edit it - how would I do this please?
Ive had a look at the doc.microsoft page and it suggests I need a 'with rs... end with' - but a bit confused how to use this.
This is my code below
Private Sub cmdFindNumber_Click()
Dim myval As Double
myval = Me!txtFindNumber
Dim rs As DAO.Recordset
Dim my_value As Variant
Dim SQL As String
Set rs = CurrentDb.OpenRecordset( _
"SELECT fldNumber FROM tbl_Data_LOI_Instructions WHERE fldNumber = " & myval & "", dbOpenSnapshot, dbReadOnly)
With Me.RecordsetClone
Do Until rs.EOF
If myval = rs![fldNumber] Then
MsgBox "Number Found", vbOKOnly
Exit Sub
End If
rs.MoveNext
Loop
MsgBox "Number Not Found", vbOKOnly
rs.Close
Set rs = Nothing
End With
End Sub