Issue: the code below opens another form (not report) that displays details of a purchase order. The form was created to mirror a gov form that we use, and the 10 line items are hard coded. when the code is run, it will display the first 10 items.
If the original form, where I am entering the purchase order info has 15 items, it doesn't push the 5 additional items on to a new page.
How would I accomplish this with what I have now?
If the original form, where I am entering the purchase order info has 15 items, it doesn't push the 5 additional items on to a new page.
How would I accomplish this with what I have now?
Code:
Private Sub btnDH_Click()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "DH01"
stLinkCriteria = "[RequisitionNumber]=" & "'" & Me![RequisitionNumber] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim i As Integer
Set db = CurrentDb
Set rst = db.OpenRecordset("SELECT * FROM tblPurchaseOrderDetails WHERE fk_RequisitionID=" & RequisitionID)
i = 1
If rst.RecordCount > 0 Then
Do Until rst.EOF
If i >= 11 Then Exit Do
Forms!DH01.Controls(i & "txtItem1") = rst("ItemDescription")
Forms!DH01.Controls(i & "txtItem2") = rst("StockNum")
Forms!DH01.Controls(i & "txtItem3") = rst("Quantity")
Forms!DH01.Controls(i & "txtItem4") = rst("UnitofIssue")
Forms!DH01.Controls(i & "txtItem5") = rst("UnitPrice")
Forms!DH01.Controls(i & "txtItem6") = rst("Quantity") * rst("UnitPrice")
i = i + 1
rst.MoveNext
Loop
End If
rst.Close
Set rst = Nothing
End Sub