form question

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

Guest

How would one go about using text boxes on a form rather than a subform to
present data? For example, I have a simple select query that returns 3
fields. I can add the query to the form as a subform but would rather instead
click a button and have 3 text fields popuate. Any ideas?
 
Brian said:
How would one go about using text boxes on a form rather than a subform to
present data? For example, I have a simple select query that returns 3
fields. I can add the query to the form as a subform but would rather instead
click a button and have 3 text fields popuate. Any ideas?


I think using a subform is probably easier. However, if the
query returns a single record, you could open a recordset on
the query and copy the fields to text boxes:

Dim db As Database
Dim rs As DAO.Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordset("yourqueryname")
txt1 = rs!fielda
txt2 = rs!fieldb
rs.Close : Set rs= Nothing
Set db = Nothing

A very crude and inefficient alternative would be to use
DLookup expressions in the three text boxes.
 
Back
Top