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

Populating a control within a subform in a tab control

Status
Not open for further replies.

devGarfield

Programmer
Mar 23, 2004
31
GB
Hi there,

I have a main form that has tab controls containing subforms to display/add information. And I need to populate the subform from a recordset.

e.g. I get a recordset for the main form, then use an ID field from it to get another recordset for the subform, which I want to populate. But I can't get to access the controls on the subform to populate them.

I have looked at "Refering a control in a tab inside another tab" (705-671375) without any luck.

Any ideas would be greatly appreciated.

Garfield
 
Can't the subform be linked to the main form with parent/child relation ?

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
It is linked, but the data is in different tables. The main form used the User table and this subform used the Client table where the userid = clientid.

The scenario is the user can enter the first & second name
and then I search for that user is found I display the details on the main form which is works, and need to do the same on the subform. The search produces a recordset, i then take the userid from that recordset and get the related client recordset using the userid. Thereafter I want to populate the fields in the subform, but can't get to the controls i.e. textbox's etc
 
Here's some of the code I've written

Private Sub LastName_AfterUpdate()
Set rstUser = CurrentDb.OpenRecordset("Users")
rstUser.Index = "UserName"
rstUser.Seek "=", Me.LastName, Me.FirstName

If Not rstUser.NoMatch Then
Me.Address = rstUser!Address
Me.Town = rstUser!Town
Me.City = rstUser!City
End If

Set rstData = CurrentDb.OpenRecordset("Clients")
rstData.Index = "PrimaryKey"
rstData.Seek "=", intUserID
If Not rstData.NoMatch Then
Forms![frmAllNewInput]![frmAllExtraClient].Form![ReferredBy] = rstData!ReferredBy
End If

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top