Imdabaum
02-16-2007, 12:27 PM
With Me.RecordsetClone
.FindFirst "PropertyID= " & Me.lstDates.Column(0) & _
" AND NoteDate= #" & Me.lstDates.Column(1) & "#" & _
" AND Memo = '" & Me.lstDates.Column(2) & "'"
If .NoMatch Then
MsgBox "The Record you selected was not found.", vbInformation, "Not Found"
Else
Me.Bookmark = .Bookmark
End If
End With
I used this code to select a record from a listbox, but it occurred to me that this would not allow for apostraphes. In order to take apostrophes into account I created 2 variables as suggested in the Help File.
Dim Q As String
Dim QQ As String
Q = Chr(34)
QQ = Q & Q
With Me.RecordsetClone
.FindFirst "PropertyID= " & Me.lstDates.Column(0) & _
" AND NoteDate= #" & Me.lstDates.Column(1) & "#" & _
" AND Memo = " & Q & Replace(Me.lstDates.Column(2), Q, QQ) & Q & _
" AND entryDate = " & Q & Me.lstDates.Column(4) & Q
If .NoMatch Then
MsgBox "The Record you selected was not found.", vbInformation, "Not Found"
Else
Me.Bookmark = .Bookmark
End If
End With
Now it properly selects all items from the listbox that have an apostrophe or double quotes, but it fails to find some of the items that don't have the apostophes. Can anyone help me find out why all items cannot be found?
.FindFirst "PropertyID= " & Me.lstDates.Column(0) & _
" AND NoteDate= #" & Me.lstDates.Column(1) & "#" & _
" AND Memo = '" & Me.lstDates.Column(2) & "'"
If .NoMatch Then
MsgBox "The Record you selected was not found.", vbInformation, "Not Found"
Else
Me.Bookmark = .Bookmark
End If
End With
I used this code to select a record from a listbox, but it occurred to me that this would not allow for apostraphes. In order to take apostrophes into account I created 2 variables as suggested in the Help File.
Dim Q As String
Dim QQ As String
Q = Chr(34)
QQ = Q & Q
With Me.RecordsetClone
.FindFirst "PropertyID= " & Me.lstDates.Column(0) & _
" AND NoteDate= #" & Me.lstDates.Column(1) & "#" & _
" AND Memo = " & Q & Replace(Me.lstDates.Column(2), Q, QQ) & Q & _
" AND entryDate = " & Q & Me.lstDates.Column(4) & Q
If .NoMatch Then
MsgBox "The Record you selected was not found.", vbInformation, "Not Found"
Else
Me.Bookmark = .Bookmark
End If
End With
Now it properly selects all items from the listbox that have an apostrophe or double quotes, but it fails to find some of the items that don't have the apostophes. Can anyone help me find out why all items cannot be found?