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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LINKING SUBFORMS please help me! 1

Status
Not open for further replies.

tigger23

Programmer
Sep 19, 2001
10
US
hi
I am trying to link 2 subforms together.. one displays some information, eg. product number and dimensions, and when the user clicks on a button next to the item number i want a subform to appear next to the first, displaying the price, value etc. relating only to the selected item. is this possible??? i can't seem to find a way to link the forms so that it shows the corresponding values only.
thanks in advance
tigger
 
In the 2nd subform's record source restrict the data to the 1st sub(...WHERE Item = Forms!MainForm!SubForm1.Form!SelectedItem), then when clicking the button requery the second sub.
 
OK, i put that code in... but it just shows up a blank area for the 2nd subform...maybe i didn't write exactly the right thing?
main form=frmMain
1st subform (no detail) = frmSubDataInput_QtrsNoDet
2nd subform (display detail of first) = frmSubDataInput_QtrsDetail
EPITEM = the field that i want to link the forms through
if possible i would also like to link the forms using a second field aswell,
EPRCUR

heres what i've got in the data source field of the 2nd subform. the first one runs off a query

[EPITEM]= forms!frmMain!frmSubDataInput_QtrsNoDet.form!EPITEM
 
I'm not sure I understand your reply correctly...

If [EPITEM]= forms!frmMain!frmSubDataInput_QtrsNoDet.form!EPITEM
is all you have in the RecordSource property of the 2nd sub
it's wrong. Insert SQL like this:

SELECT * FROM Table WHERE Table.epitem = forms!frmMain!frmSubDataInput_QtrsNoDet.form!EPITEM;



 
ok. the first subform runs from a query which uses 2 tables. the query picks up criteria information from the main form where it is embedded, (frmDataInput_Qtrs), and another form (frmMain).
do i need to write another query to run the second subform from?? i tried the code you gave me just now (also tried changing table.epitem to qryDataSelection.epitem, which is the name of the query that the 1st subform runs off.), and theres a blank space where the 2nd subform should be.

(you'll have to excuse me if i'm just being thick... that'll be cos of the blonde hair!)

 
Well I'm blonde too, perhaps I can't get your problem correctly...

But let's give it another try

1st some questions (in brackets are the answers I assume are correct):

Is there all the info you need for 2nd sub in the query of the 1st sub?(yes)

Are you using requery method after clicking the button? (no)

If I'm right with answers here's the solution that should work:

1. In the RecordSource of 2nd sub open QueryBuilder and create the same query as for the 1st, but add the following criteria under the field EPITEM:
forms!frmMain!frmSubDataInput_QtrsNoDet.form!EPITEM
(if you use different name of text box that is bound to a filed EPITEM, use this name)

2. In the OnClick event procedure of a button add the following line of code:
Forms!frmMain!frmSubDataInput_QtrsDetail.Form.Requery

I hope I'm on the right track. Let me know.


 
THANKYOU!!!!
it looks like it is finally working!!
it was the requery bit that was messed up... i had put some code in there before, but it hadn't worked, i'm not sure exactly why, but.... there you go!
thanks ever so much for your help!
tigger
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top