C
Curtis Stevens
I have two combo boxes:
Search By Combo
Search For Combo
You select the field column name in BY and type in the name or data in the
FOR. For example, you want to search company name field and you type in ABC
Flowers in the FOR box.
It works, except when I type in a ' in the FOR combo, like ABC's Flower
I tried it & click debug and access highlights this line of code (MARKED
THIS LINE WITH >><<)
Private Sub SearchFor_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
Me.SearchFor = Null
End Sub
NO ERROR, for you reference:
Private Sub SearchBy_AfterUpdate()
Me.SearchFor.RowSourceType = "Table/Query"
Me.SearchFor.RowSource = "SELECT DISTINCT [" & _
Me.SearchBy & "] FROM [" & _
Me.SearchBy.RowSource & _
"] ORDER BY [" & Me.SearchBy & "]"
End Sub
Thanks!
Curtis
Search By Combo
Search For Combo
You select the field column name in BY and type in the name or data in the
FOR. For example, you want to search company name field and you type in ABC
Flowers in the FOR box.
It works, except when I type in a ' in the FOR combo, like ABC's Flower
I tried it & click debug and access highlights this line of code (MARKED
THIS LINE WITH >><<)
Private Sub SearchFor_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[" & Me.[SearchBy] & "] Like '" & Me![SearchFor] & "*'"rs.FindFirst "[" & Me.[SearchBy] & "] = '" & Me![SearchFor] & "'" <<<<<
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
Me.SearchFor = Null
End Sub
NO ERROR, for you reference:
Private Sub SearchBy_AfterUpdate()
Me.SearchFor.RowSourceType = "Table/Query"
Me.SearchFor.RowSource = "SELECT DISTINCT [" & _
Me.SearchBy & "] FROM [" & _
Me.SearchBy.RowSource & _
"] ORDER BY [" & Me.SearchBy & "]"
End Sub
Thanks!
Curtis