View Full Version : LOOKUP DATA


DREWN
01-09-2001, 05:32 PM
THERE SEEMS TO BE A PROBLEM,
I CREATED A FORM FROM A QUERY.
IT IS A MAIN/SUBFORM FORM. IN THE SUBFORM I WANT TO BE ABLE TO ENTER ONE FIELD AND HAVE ALL THE RELATED DATA ATTACHED TO THAT RECORD AUTOMATICALLY APPEAR IN THEIR APPROPRIATE FIELDS. I ALSO HAVE OTHER FIELDS AROUND IT JUST FOR DATA ENTRY. I WANT TO BE ABLE TO ENTER AS MANY RECORDS I WANT TO IN THE SUBFORM. THE DATABASE'S STRUCTURE IS ALREADY WHOLE I JUST WANT THIS DATA EXTRACTED FROM THE QUERY.PLEASE HELP

ntp
01-11-2001, 08:48 AM
You can create a query to be run when the user enters a value into the controlling field. Once this query is run create a recordset based on this query then fill in the related fields one by one.

All this can go in the controlling field's afterupdate event.

for example:

private sub yourcontrol_afterupdate ()
set rsttemp = currentdb.querydef("some query").openrecordset
rsttemp.filter = '[somefield] = '" & me.yourcontrol & "'"
set rst = rsttemp.openrecordset
with rst
me.control1 = !field1
me.control2 = !field2
... you get the idea
End with
rsttemp.close
rst.close
set rsttemp = nothing
set rst = nothing
end sub




[This message has been edited by ntp (edited 01-11-2001).]