how to store values in subform

ckib

Board Regular
Joined
Sep 14, 2005
Messages
219
Hi everyone, here is my latest challenge. I need to look up values in a table, then store those values into a control on a subform. So, for each record in tblIndustry I need to store the value of the field 'industry'. My code doesn't work if there are multiple industry records for a contact ... because all the values are stored into the same control. Could someone tell me how to "reference" mutiple occurrences in the subform? Here is my code so far ... Thanks!

' find industry records from source contact

strSQL = "SELECT * FROM tblIndustry WHERE (((tblIndustry.in_contactID)=" & lngContactID & "));"

Set myRS = myDB.OpenRecordset(strSQL)

' add new industry values to subform

myRS.MoveFirst

Do Until myRS.EOF
Forms![frmContact]![frmContactIndustry_Sub]![List_industry].Value = myRS!industry
myRS.MoveNext
Loop

myRS.Close
Set myRS = Nothing
 
No, it didn't do the trick ... I think because the subform is bound to the "child" record of the main form and I'd be trying to "add" records on the subform in a loop. I don't know if this can be done ... if anyone knows, please tell me! Thanks.
 
Upvote 0

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Forum statistics

Threads
1,215,730
Messages
6,126,527
Members
449,316
Latest member
sravya

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top