What is your source for Combo1? I get an error because you are using the
rowsource in the From statement
put a debug.print at the end of this code and see if it says what you think
it should say...
Private Sub SearchBy_AfterUpdate()
Me.SearchFor.RowSourceType = "Table/Query"
Me.SearchFor.RowSource = "SELECT DISTINCT [" & _
Me.SearchBy & "] FROM [" & _
Me.SearchBy.RowSource & _
"] ORDER BY [" & Me.SearchBy & "]"
Here is what i get when I do the debug.print : SELECT DISTINCT [mytable]
FROM [1] ORDER BY [1]
I would do it differently:
var1=me.SearchFor.Text
Me.SearchFor.RowSource = "SELECT mytable.ID,mytable.Name, mytable.Title,
mytable.Extension, from mytable where ((mytable.Name)= " & "'" & Var1 & "'"
& ")"
me.searchfor.requery
The results in the second combobox are then all of the names that are the
same.
Since I don't know what your tables look like or what the row source of
Searchby is, this is just guesswork on my part.
Damon
Curtis Stevens said:
Combo 1 = Search By
Combo 2 = Search For
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
Private Sub SearchFor_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[" & Me.[SearchBy] & "] = " & Chr(34) & Me![SearchFor] &
Chr(34)
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
Me.SearchFor = Null
End Sub