Requering listbox records based on another listbox

TimTDP

Registered User.
Local time
Tomorrow, 00:46
Joined
Oct 24, 2008
Messages
213
I have 2 list box's on a form

lstPaymentDate = SELECT DISTINCT PaymentDate FROM tblPayment ORDER BY PaymentDate DESC;
lstSelectEmployee = SELECT tblPayment.EmployeeWageId FROM tblPayment WHERE (((PaymentDate) Like [Forms]![frmPrintPayment]![lstPaymentDate]));

Code:
Private Sub lstPaymentDate_AfterUpdate()
Me.lstSelectEmployee.Requery
end sub

This works perfectly

I have now added a command button

Code:
Private Sub cmdOneClickAll_Click()
Me.lstPaymentDate.Selected(0) = True
Me.lstSelectEmployee.Requery
end sub

When I click on the button, the 1st record in lstPaymentDate is selected, but no records appear in lstSelectEmployee (There are records!!!)

How do I get the records to display in lstSelectEmployee ?

Thanks in advance
 
Maybe try assigning the first row value to the listbox instead.
 
Try replacing the Like with =
 
If there is time component, use DateValue(fieldname) to extract date part.
 
I also asked in the other thread on UA:

Please clarify whether lstPaymentDate is a single-select or multi-select listbox.

If its Multi Select property is set to anything other than "None" then the Rowsource will not work as you intend:
Code:
lstSelectEmployee = SELECT tblPayment.EmployeeWageId FROM tblPayment WHERE PaymentDate = [Forms]![frmPrintPayment]![lstPaymentDate];
 
Thanks for the help so far. But I simply cannot get it to work!
I have attached the database.

On the form that opens is a button. If the button is pressed, the second record in lstPaymentDate should be selected and lstSelectEmployee requeried.

Thanks in advance
 

Attachments

1-line code change required:

Change to:
Code:
Private Sub cmdOneClickAll_Click()
Me.lstPaymentDate = Me.lstPaymentDate.ItemData(0)
Me.lstSelectEmployee.Requery
end sub
 

Users who are viewing this thread

Back
Top Bottom