Autofilling a field in a form from data in a query

P

Paul

If a field in a query has focus, how can I populate a field in a form with
that value?
 
K

Klatuu

There is no such thing as a field in a query having the focus. Only controls
on a form can have the focus or, if a form has no controls that can accept
the focus, the form can accept the focus.

If you can explain what it is you are trying to do, perhaps we can help with
the how to do it.
 
P

Paul

When I open a query, there may be a requirement to request more information
about that record. To do so, I have a form that loads from a button on a
switchboard. The field which identifies the record of interest is called
Control_Number.

The form which I need to fill out needs that Control_Number as a required
field.

I'd like to autofill the Control_Number "control" on the form with the data
from the Control_Number field in the query record I have highlighted.

Thanks
 
K

Klatuu

The form being opened will have no way of knowing anything about the query,
especially when opened from a switchboard (assuming you mean the Access
switchboard).

If instead of a raw query, you create a datasheet form, you can use the Load
event of the form you are opening from the switchboard to populate the
control. The code would be something like:

If CurrentProject.AllForms("DatasheetFormName").IsLoaded Then
Me.Control_Number = Forms!DatasheetFormName!Control_Number
End If
 
Top