Passing parameter from Form to Sub-form

utzja1

Registered User.
Local time
Today, 03:49
Joined
Oct 18, 2012
Messages
97
I am using the following statement to pass the value from a ComboBox (Combo38) on the main form to a field on a subform (BridgeMaintItems). The statement below only seems to modify the StrID field in the first record on the subform. For my append query to work correctly, I need to update the StrID field in every record (+/- 40 records).

Me.BridgeMaintItems_subform1.Form![StrID] = Me.[Combo38]

Any thoughts? Seems like it should be easy, but I feel like the syntax is only setting the value in the subform's first record since it is the default "active" record when the subform is open.

Many thanks for your time!
 
Modify the subreport record source to reflect the records you want utilizing bookmarks.
 
Thanks for the feedback!

I went back and read my initial post and I may not have communicated my goal as thoroughly as I should have. I want the value selected in the combo box to be inserted in the [StrID] field of every record in the subform. I think your suggestion would pull in the value of all the structure ID's.

I'm using the subform to enter maintenance items into another table by an append query. There are too many items to make a drop-down list a possibility, so my solution was to put a checkbox in the subform datasheet (append query is launched by a command button). When the user clicks the command button, only the maintenance items that are checked "Yes" will be appended to the main table. I need the StrID field populated so the records can be queried from the other table, and a combo-box seemed like a good idea so that the user doesn't have to enter the structure number in the record of each maintenance item.

Sorry if I wasn't clear. Would your suggestion still work?
 
Figured it out. I realized that I should have been looking at an update query to accomplish this. I built a SQL statement using a string and added the combo box value to it. Now when the combo box is updated, the StrID field in all the records is automatically updated. Thanks for your response!

Dim strSQL As String
Dim strSTR As String

strSTR = Forms![AddMntItemsF]![Combo38]
strSQL = "UPDATE BridgeMaintItems SET BridgeMaintItems.StrID = " &_ strSTR

DoCmd.RunSQL (strSQL)
 

Users who are viewing this thread

Back
Top Bottom