Dear Gents ,
I have a form that contains some IT Assets I need to print only selected items from all items and print them with their quantities .. I already tried to do it but i only succeeded in printing them all with their quantities , But now i need to print only selected items
Here is the code an i hope to help me
Code:
Dim rs As DAO.RecordsetDim i As Long
Dim task As String
Set rs = Me.RecordsetClone
Dim msg, Button, Title, Response
msg = "Are you sure you want to print these items ? "
Button = vbYesNo + vbDefaultButton2
Title = "Easy cash V. 1.0"
Response = MsgBox(msg, Button, Title)
If Response = vbYes Then
If Not (rs.BOF And rs.EOF) Then 'make sure we have records to loop through
rs.MoveFirst 'make sure we're on the first record
Do While Not rs.EOF 'keep looping until we reach the end of the recordset
For i = 1 To rs!qty
RedefRptSQL "Copy Of BarcodeMaker_4cmSize2", "SELECT Category.Category, Info.Name, * FROM Info, Category INNER JOIN Products ON Category.CatID = Products.Category WHERE (((Products.ItemID)='" & rs!ItemID & "') AND ((Products.[checked])=True));"
DoCmd.OpenReport "Copy Of BarcodeMaker_4cmSize2", acViewNormal
Next i
rs.MoveNext
Loop
End If
rs.Close
Set rs = Nothing
Else
End If
here is the defentition of RedefRptSQL Function " I found this function on this forum btw "
Code:
On Error GoTo Error_Handler
Dim Rpt As Report
DoCmd.OpenReport sRptName, acViewDesign, , , acHidden 'Open in design view so we can
'make our changes
Set Rpt = Application.Reports(sRptName)
Rpt.RecordSource = sSQL 'Change the RecordSource
DoCmd.Close acReport, sRptName, acSaveYes 'Save our changes
Error_Handler_Exit:
On Error Resume Next
Set Rpt = Nothing
Exit Function
Error_Handler:
MsgBox "The following error has occured." & vbCrLf & vbCrLf & _
" Error Number: " & err.Number & vbCrLf & _
" Error Source: RedefRptSQL" & vbCrLf & _
" Error Description: " & err.description, _
vbCritical, "An Error has Occured!"
Resume Error_Handler_Exit
End Function