open a record from a Listbox

G

Guest

I have an unbound form with an unbound listbox. The listbox is pulling infor
from a query that reads as follows

SELECT weeklytest.Week, weeklytest.Dayweek FROM weeklytest;

The out put is week # and the dates that that week represent.

I have an event procedure that if you double click the item in the listbox
its supposed to open the report Weekly team2 track.
the following is the code that I have in the event procedure for opening the
report but its opening all the records but I only want it to open for that
week that I selected.....

Private Sub List4_DblClick(Cancel As Integer)
On Error GoTo Err_List0_DblClick

Dim DocName As String

DocName = "Weekly team2 track"


DoCmd.OpenReport DocName, acPreview

Exit_List0_DblClick:
Exit Sub

Err_List0_DblClick:
MsgBox Err.Description
Resume Exit_List0_DblClick

End Sub




Please help!
 
G

Guest

Your open report does not specify which record to print which is why you get
every record.
It needs to be something like this depending on your form name, field names,
list box name etc.

DoCmd.OpenReport DocName, acPreview,,"[DayWeek] = " &
Forms!NameOfForm!ListBoxText
 
G

Guest

I am having a problem with the following code

DocName = "Monthly Employee Tracking"

DoCmd.OpenReport DocName, acPreview, , "[Months]=" & Forms![Search Monthly
Employee]![List4]

DocName is the name of the report, infor in the listbox(list4) is coming
from a qry, months is dervived from [trackdate]----Format$([TrackDate],"mmmm
yyyy",0,0). What I would like to do is to click on the month and it should
be able to open the report with that month.



Please help
Dennis said:
Your open report does not specify which record to print which is why you get
every record.
It needs to be something like this depending on your form name, field names,
list box name etc.

DoCmd.OpenReport DocName, acPreview,,"[DayWeek] = " &
Forms!NameOfForm!ListBoxText

JOM said:
I have an unbound form with an unbound listbox. The listbox is pulling infor
from a query that reads as follows

SELECT weeklytest.Week, weeklytest.Dayweek FROM weeklytest;

The out put is week # and the dates that that week represent.

I have an event procedure that if you double click the item in the listbox
its supposed to open the report Weekly team2 track.
the following is the code that I have in the event procedure for opening the
report but its opening all the records but I only want it to open for that
week that I selected.....

Private Sub List4_DblClick(Cancel As Integer)
On Error GoTo Err_List0_DblClick

Dim DocName As String

DocName = "Weekly team2 track"


DoCmd.OpenReport DocName, acPreview

Exit_List0_DblClick:
Exit Sub

Err_List0_DblClick:
MsgBox Err.Description
Resume Exit_List0_DblClick

End Sub




Please help!
 

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