can't print out what's on the listbox to the report

associates

Registered User.
Local time
Today, 11:08
Joined
Jan 5, 2006
Messages
94
Hi,

I was wondering if anyone might be able to help me here. I have two tables, staff_table and salary_table.

Staff_table has the following fields,
Staff_ID, Staff_FN, Staff_LN,...

Salary_table has the following fields,
Sal_ID, Staff_ID, Sal_Date, Pay_Amt,...

In the salary form, i have a listbox that shows records of the joining of the two tables, because i'd like to be able to show the FirstName and LastName of staff. So Staff_table is joined to Salary_table via Staff_ID.

And also, in the form, i have a button to print out whatever's listed out in the listbox. It also has a combobox that is to filter the records by Staff_ID.

The salary report is created using the query named QSalary. QSalary is as a result of the joining of the two tables, Staff and Salary.

I hope i haven't lost you this far.

What doesn't work is when i filter by the Staff_ID of 10(michael), i can see there are a few number of records shown just for michael and i want to have them printed out on the report but it doesn't work. it shows the whole records in the salary table.

Here is my code

nlist = Me.LB_Salarylist.ListCount

For ncount = 0 To nlist - 1
stlinkcriteria = ",'" & Me.LB_Salarylist.ItemData(ncount) & "'" & stlinkcriteria
Next ncount

If Len(stlinkcriteria) > 0 Then
stlinkcriteria = "[QSalary.Sal_ID] In (" & Mid(stlinkcriteria, 2) & ")"
' i have tried [Sal_ID] and [Salary_table.Sal_ID], none of them work.
End If

stDocName = "Salary_SumReport" ' for producing salary summary report

DoCmd.OpenReport stDocName, acPreview

Your help is greatly appreciated.

Thank you in advance
 
Sorry if I'm stating the obvious but you haven't included your stlinkcriteria in the openreport call.

If that's not your problem then I'd use debug.print to examine the result of stlinkcriteria and copy it into a source query to see if it's having the desired effect on the source data.

hth
Chris
 
Hi Stopher,

Thank you for your reply.

It works now. No, you're right. it's a clumsy of me for not being able to pay attention to that obvious missing link criteria in the openreport call. I must've been half asleep while doing that.

It works well now.

Thank you for pointing that out.
 

Users who are viewing this thread

Back
Top Bottom