Query design problems

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm having a brain cramp. I am trying to create a query on a form where you
can type in a value in a text box, and if that value is in the table the
information for that value is displayed on the form. Is there an easy way to
do this? Thanks in advance!
 
Your request is a bit vague. Is this value you are typing in the primary key?
If not, you could get back several matches. So you would need a listing and
selection mechanism like a combo box or listbox. Once you have determined the
single record you want, run a DoCmd.ApplyFilter command to display the
desired record.

-Dorian
 
Make the text box unbound, and in the AfterUpdate event of the text box
change the RecordSource of the form to include the criteria from the text
box. Something like:

Sub txtMyBox_AfterUpdate()
Me.RecordSource = "SELECT ... FROM
WHERE [field1]='" & txtMyBox
& "'"
End Sub

Note the single quotes around the value from txtMyBox. If this will be
anumeric value instead of a string value, you can omit the single quotes:

Me.RecordSource = "SELECT ... FROM
WHERE [field]=" & txtMyBox

Carl Rapson
 
Back
Top