view query results in subform

J

john

i want to create a form where i can type in a figure e.g. Customer ID and i
want to press a search button that will run a query to match the Customer Id
and return results in a subform on the same form where i search from.


thnx in adv
 
D

David Lloyd

John:

You can use the Link Child Fields and Link Master Fields properties of the
subform to do this. The value in the Link Master Fields should be the name
of the CustomerID text box, for example txtCustomerID. The value of the
Link Child Fields should be the field name, for example [CustomerID], in the
table or query referenced in the Source Object property of the subform.

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.
 
A

Alex White MCDBA MCSE

Hi John,

the txtCustomer_ID text should not be bound to the recordset as it will
corrupt your data

dim adoTest as new adodb.recordset
dim SQL as string
SQL = "Select * as Total from TblCustomer Where Customer_ID=" &
me.txtCustomer_ID.value
with adoTest
.open SQL, currentproject.connection, adOpenKeyset, adLockOptimistic
if .recordcount > 0 then
me.recordsource = SQL
' or the sub form record source
me.requery
else
msgbox "Customer not found!"
end if
.close
end with
 
Top