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
 

ckib

Board Regular
Joined
Sep 14, 2005
Messages
219
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.
 

Some videos you may like

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Watch MrExcel Video

Forum statistics

Threads
1,122,472
Messages
5,596,354
Members
414,060
Latest member
hermanseck

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
Top