is this posible in a list box

G

Guest

I have a unbound form that has undound combo box and unbound listbox.... What
am doing is selecting an employees name from the combo box and the listbox is
populated with which months ( ie I formated the months as follows
=Format$([TrackDate],"mmmm yyyy",0,0))they worked stuff on.
When I click on an item from the listbox, it opens everyone elses stuff for
that month and not that just specific employee... this is the code I have for
opening the report
Private Sub List4_DblClick(Cancel As Integer)

Dim DocName As String

DocName = "Monthly Employee Tracking"

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

End sub

The following is the sql statement that I have that the list box infor
contains!

SELECT DISTINCT Format$([TrackDate],"mmmm yyyy",0,0) AS Months,
Tracking.EmplID
FROM Tracking
GROUP BY Format$([TrackDate],"mmmm yyyy",0,0), Tracking.EmplID
HAVING (((Tracking.EmplID)=[Forms]![Search Monthly Employee]![cmbsrchEmpl]))
ORDER BY Tracking.EmplID;


Please help
 
J

John Vinson

When I click on an item from the listbox, it opens everyone elses stuff for
that month and not that just specific employee... this is the code I have for
opening the report
Private Sub List4_DblClick(Cancel As Integer)

Dim DocName As String

DocName = "Monthly Employee Tracking"

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

End sub

Well.. that's what you're asking for. You're opening the report with a
criterion on the months, with no indication of which student you want.

Try changing the OpenReport to something like

DoCmd.OpenReport DocName, acViewPreview, , _
"[Months]='" & Forms![Search Monthly Employee]![List4] & "'" _
& " AND [EmployeeID] = " & Forms![Search Monthly Employee]![ComboX]

using the combo box containing the employee ID.

John W. Vinson[MVP]
 
G

Guest

Thank yo so much this worked perfectly!

John Vinson said:
When I click on an item from the listbox, it opens everyone elses stuff for
that month and not that just specific employee... this is the code I have for
opening the report
Private Sub List4_DblClick(Cancel As Integer)

Dim DocName As String

DocName = "Monthly Employee Tracking"

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

End sub

Well.. that's what you're asking for. You're opening the report with a
criterion on the months, with no indication of which student you want.

Try changing the OpenReport to something like

DoCmd.OpenReport DocName, acViewPreview, , _
"[Months]='" & Forms![Search Monthly Employee]![List4] & "'" _
& " AND [EmployeeID] = " & Forms![Search Monthly Employee]![ComboX]

using the combo box containing the employee ID.

John W. Vinson[MVP]
 

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