Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending control value to subform

Status
Not open for further replies.

bfamo

Technical User
Feb 16, 2006
132
0
0
NO
Hi!

I have three forms:
frmSearch (Based on a query, contains a control [CaseID])
frmCustomer (With control [CustomerID])
frmCustomerSub (With control [CaseID])

Here is what is supposed to happen:

When I press button btnNext in frmSearch, the value in frmSearch!CaseID is passed to frmCustomer!frmCustomerSub.Form!CaseID.

Code:
DoCmd.OpenForm "FrmCustomer", acNormal, , "Me![FrmCustomerSub].Form![CaseID]=Forms![FrmSearch]![CaseID]"

I have tried this code, but it looks as if the code can't find the control I'm refering to. I get prompted to insert a value for Me![FrmCustomerSub].form![CaseID].


Can someone please help me with this?
 
The Fourth prameather in open form is the where condishion

the syntex is
fieldname=value

not controlname=xxx

 
Like Pwise said you need a Sql Where clause without the word "where".

"CaseID = " & Forms![FrmSearch]![CaseID]

Unless caseID is text then

"CaseID = '" & Forms![FrmSearch]![CaseID] & "'
 
Thanks for quick response :)

When refering to the CaseID-field in frmCustomerSub, I have to include [Red]"Me!frmCustomerSub!CaseID"[/Red], right?
If I dont do, I would basically say that the CaseID-field is located on frmCustomer and not on its subform.
 
I might be confused, but when you open frmCustomer don't you want to go to a specific record on the main form and show all related records in the sub? Or is the main form unbounded and the subform shows your records?

if it is the latter then in the search form
Code:
DoCmd.OpenForm "FrmCustomer", acNormal
forms("frmCustomer").frmCustomerSub.form.recordset.findfirst "[CaseID]= " & me![CaseID]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top