report variables from form list

C

cms

I have a table that lists shifts(shiftdetails) including their date/time. I
have a listbox that is a query of those and shows the last 10 shifts.

I would like the user to select one shift from the listbox, and hit a button
to generate a report using shiftid as a variable.

I currently have the report working, along with the where condition. I just
can not figure out how to pass the selected records shiftid value to it.

Private Sub previewrep_Click()
On Error GoTo Err_previewrep_Click

Dim stDocName As String
stDocName = "logs"
DoCmd.OpenReport stDocName, acPreview, , "shiftid = 48"
Exit_previewrep_Click:
Exit Sub
Err_previewrep_Click:
MsgBox Err.Description
Resume Exit_previewrep_Click
End Sub
 
C

cms

To answer my own question... I used the following code and changed the bound
column to the correct one with the shiftid. All working now



stDocName = "logs"
Debug.Print Me!List0.ItemData(Me.List0.ItemsSelected(0))
DoCmd.OpenReport stDocName, acPreview, , "shiftid=" & Me!List0.ItemData
(Me.List0.ItemsSelected(0))

I knew I would figure it out after posting, should have posted a few days ago
:)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top