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

Populate Details in SubForm

Status
Not open for further replies.

ragu111

MIS
Aug 15, 2002
129
AE
i have made a contact list in access. with two tables

Table1 have the company name and Head_ID
Table2 have contact details

both Table linked with Head_ID and Details_ID

on the form i want to display all the company name one side on a ListBox. otherside i have the subform with contact details.

what i want is, when i ckick the company name in ListBox, subform should show the contact details for the selected company.

ragu [pc]
 
Hi
You can use the After Update Event:
Code:
Private Sub [i]ListBoxName[/i]_AfterUpdate()
Me.[i][ContactDetailsSubformControlName][/i].Form.RecordSource = "Select * From [i][ContactDetailTableName][/i] Where  Details_ID = " & Me.[i]ListBoxName[/i] 
End Sub

The above is for numeric link fields, if the link fields are text, you need:
='" & Me.ListBoxName & "'"
Your list box must have Head_ID as the Bound Column.
 
tks remou,

i tried but i'. getting an error. below is my code

Code:
Private Sub Head_List_AfterUpdate()

Me.Head_id.from.RecordSource = "select * from details where head_id = " & Me.Head_List

End Sub

ragu [pc]
 
Hi
If this is a cut and paste, there is a typing error:
Me.Head_id.[red]from[/red].RecordSource
This should be form:
Me.Head_id.form.RecordSource
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top