Public Sub CreateOrderLines(frm As Form, strFormName As String, strSubformName As String)
Dim rsSourceLines As Recordset
Dim strAfterUpdate As String
strAfterUpdate = ("cboSOLinesID_AfterUpdate") 'even better would be strAfterUpdate = (strControlName & "_AfterUpdate")
Set rsSourceLines = CurrentDb.OpenRecordset("SELECT " & strTableName & "." & strFieldName & ", " & strTableName & ".UnitsID, " & strTableName & "." & strSelectField & ", " & strTableName & ".WarehouseID, tblSOHeader.PVID, tblSOHeader.dtmDate, tblItems.VendorsID " _
& "FROM tblItems INNER JOIN (tblSOHeader INNER JOIN " & strTableName & " ON tblSOHeader.SOHeaderID = " & strTableName & ".SOHeaderID) ON tblItems.ItemsID = " & strTableName & ".ItemsID " _
& "WHERE (((" & strTableName & "." & strSelectField & ") > 0) And ((tblSOHeader.SOHeaderID) = " & frm![txtSOHeaderID] & strCreateOrderLinesWhere & varVendorWhere & ")) " _
& "ORDER BY " & strTableName & "." & strFieldName & "; ")
DoCmd.OpenForm strFormName
DoCmd.GoToRecord acDataForm, strFormName, acLast
With Forms(strFormName).Controls(strSubformName).Form
Do Until rsSourceLines.EOF
.Recordset.AddNew
.Controls(strControlName) = rsSourceLines(strFieldName)
.lngUnitQuantity = rsSourceLines(strSelectField)
.UnitsID = rsSourceLines!UnitsID
.(strAfterUpdate) 'This would work if I typed cboSOLinesID_AfterUpdate, but how do I make it work with a variable?
.Dirty = False
rsSourceLines.MoveNext
Loop
End With
End Sub
Thank you.Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Most Valuable Expert award recognizes technology experts who passionately share their knowledge with the community, demonstrate the core values of this platform, and go the extra mile in all aspects of their contributions. This award is based off of nominations by EE users and experts. Multiple MVEs may be awarded each year.