link subform within subform

N

Noemi

Hi

I seem to be having issues making my subforms work.

I have pasted the code i currently have below.

What I am trying to do is the following.
1- I have Form1 which has a tabcontrol with 2 pages.
2- The second page of the tabcontrol contains a few text boxes and a
combobox plus another tabcontrol which has 4 pages
3- The combobox is the control which when a persons name is selected then
all the textboxes are populated with the data applicable to the name, however
I also would like the each page in the tabcontrol which has subforms attached
to each one which refernce tables with data which uses the NameID as the link
field

So in summary I have 1 Subform called Form2 on Form1 & 4 subforms on Form2
and I need to be able to get the tables in the subforms on form 2 to show the
data against the name of the person who is selected fromt he combobox on Form2

The code below doesn't seem to work as I keep getting errors. I tried to
place the StaffID and CasualNo into CHild and Master for each of the
subsubforms however when I open the form it asks for the value as there is no
value until a selection is made from the combobox.

Dim rs As DAO.Recordset
Dim rs2 As DAO.Recordset
Dim rs3 As DAO.Recordset

Set rs = CurrentDb.OpenRecordset("tbl_CasualsDetails", 2)
Set rs2 = CurrentDb.OpenRecordset("qry_Status", 2)
Set rs3 = CurrentDb.OpenRecordset("tbl_Dates", 2)


rs.FindFirst "[No]=" & Me!cboName & ""
If Not rs.NoMatch Then
Me!HomeNo.Value = rs.Fields(3).Value
Me!MobileNo.Value = rs.Fields(4).Value
Me!Email.Value = rs.Fields(5).Value
Me!Address.Value = rs.Fields(2).Value
Me!EmergencyContact.Value = rs.Fields(6).Value
Me.StaffID.Value = rs.Fields(0).Value
End If
Me.Form2!StaffID = rs.Fields(0).Value
rs2.FindFirst "[No]=" & rs.Fields(0).Value & ""
Me!Status.Value = rs2.Fields(0).Value
[Forms]![Form1]![Form2].LinkChildFields =
[Forms]![Form1]![Form2]![qry_Comments subform1].CasualNo
[Forms]![Form1]![Form2].LinkMasterFields = [Forms]![Form1]![Form2].StaffID

Thanks
Noemi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top