Cascasding Combos

No all that code is the After Update of the Employee combo (CboEmployees).

The Load() code is on its own.

My Date combo looks like this so far but it still doesnt refresh either when selecting a new employee.:

Private Sub CboPaymentDate_AfterUpdate()
Me.TxtGrossPay = Me.CboPaymentDate.Column(7)
Me.TxtExpenses = Me.CboPaymentDate.Column(6)
Me.TxtPaymentID = Me.CboPaymentDate.Column(1)
LngPaymentID = Me.TxtPaymentID

End Sub

My whole code for the form looks like:

Option Compare Database
Private Sub CboPaymentDate_AfterUpdate()
Me.TxtGrossPay = Me.CboPaymentDate.Column(7)
Me.TxtExpenses = Me.CboPaymentDate.Column(6)
Me.TxtPaymentID = Me.CboPaymentDate.Column(1)
LngPaymentID = Me.TxtPaymentID
Me.TxtGrossPay = Null
Me.TxtExpenses = Null
Me.TxtPaymentID = Null

End Sub

Private Sub CboEmployees_AfterUpdate()
Me.TxtNI = Me.CboEmployees.Column(2)
Me.TxtBand = Me.CboEmployees.Column(3)
Me.TxtPensionRate = Me.CboEmployees.Column(4)
Me.TxtPCT = Me.CboEmployees.Column(5)
Me.TxtNonCont = Trim(Me.CboEmployees.Column(6) & " ")
Me.TxtID = Me.CboEmployees.Column(0)
LngEmployeeID = Me.TxtID
Me.CboPaymentDate.RowSource = "Select [Session Date] From QryHistory Where [GPID] =" & Me.CboEmployees & " Order By [Session Date] DESC;"
Me.CboPaymentDate.Requery



End Sub


Private Sub Form_Load()
LngEmployeeID = 0
LngPaymentID = 0
Me.CboEmployees.SetFocus
Me.CboPaymentDate.SetFocus


End Sub
 
You posted code for "Private Sub CboEmployees_AfterUpdate()" but asking a question about the date combo... ??

The date combo is below, which you posted now...

Code:
Private Sub CboPaymentDate_AfterUpdate()
[B]Me.TxtGrossPay [/B]= Me.CboPaymentDate.Column(7)
[U]Me.TxtExpenses[/U] = Me.CboPaymentDate.Column(6)
Me.TxtPaymentID = Me.CboPaymentDate.Column(1)
LngPaymentID = Me.TxtPaymentID
[B]Me.TxtGrossPay[/B] = Null
[U]Me.TxtExpenses[/U] = Null
Me.TxtPaymentID = Null

End Sub

And WOW whats going on here???
 
You posted code for "Private Sub CboEmployees_AfterUpdate()" but asking a question about the date combo... ??

The date combo is below, which you posted now...

Code:
Private Sub CboPaymentDate_AfterUpdate()
[B]Me.TxtGrossPay [/B]= Me.CboPaymentDate.Column(7)
[U]Me.TxtExpenses[/U] = Me.CboPaymentDate.Column(6)
Me.TxtPaymentID = Me.CboPaymentDate.Column(1)
LngPaymentID = Me.TxtPaymentID
[B]Me.TxtGrossPay[/B] = Null
[U]Me.TxtExpenses[/U] = Null
Me.TxtPaymentID = Null
 
End Sub

And WOW whats going on here???

Hi, yes those have been taken out, I was putting them in the date and employee updates just to check what happened, nothing did. They have been removed now.

It is about the date combo, it wont populate fields when I select a date.

I seem to be rambling now, so I will lay out clearly whats happening...

  1. Employee combo (CboEmployees) is working fine, it self populates its required fields and also filters the Payment Date (CboPaymentDate) field based on which employee is selected, as it should do.
  2. When I select a date from CboPaymentDate, nothing self populates, I have code in for this (see previous code but ignore the "null" parts of it, they have gone) that is practically same as CboEmployees but nothing happens.
  3. When I select a date, if I then select a new employee from CboEmployees the date in CboPaymentDate stays the same, I need it to start off again as blank or at least with a date that matches the employee.
Sorry for the confusion.
 
If you removed the null lines, it should work fine...

I made a quick sample for you to look at ...
 

Attachments

I have it set up as yours, however when I select the date, I get a different error now saying the "The value you entered isn't valid for this field"

For example; you may be entering text into a numeric field or a number that is larger than the FieldSize settings permits.

Where do I find the field size?

The boxes I am using on the form are text boxes.
 
OK had a look at the database you send me...

Couple of things...
1)
Code:
Private Sub Form_Load()
    LngEmployeeID = 0
        Me.CboEmployees.SetFocus
End Sub
Why set the focus upon form load?? Probably because you dont know you can set the order of the controls...
When you have the form open in design mode, go in the menu to View > Tab Order, here you can determain the order of the controls... no need for the focus thing...

2) "The value you entered isn't valid for this field"
Your rowsource IS NOT QryHistory, but its an SQL Statement
Code:
    Me.CboPaymentDate.RowSource = "Select [Session Date] From QryHistory Where [GPID] =" & Me.CboEmployees & " Order By [Session Date] DESC;"
    Me.CboPaymentDate.Requery
this select statement only has 1 column, not more.. thus the data you fetch using Me.TxtPaymentID = Me.CboPaymentDate.Column(1) will not return anything, throwing the error.... You can solve this by putting in the proper sql into the rowsource instead of above SQL.
The rowsource for the Date Combo should be:
Code:
SELECT payments.GPID, payments.ClaimID AS [Claim Id], payments.DateofSession AS [Session Date], rate_tbl.[Type of Rate] AS [Rate Type], payments.RateofPay AS [Rate £p], payments.HoursWorked AS Hours, payments.MileageClaim AS Mileage, payments.TotalClaim AS [Total £p]
FROM payments INNER JOIN rate_tbl ON payments.TypeofRate = rate_tbl.rate_ID
WHERE (((payments.GPID)=[Forms]![GPSOLO]![CboEmployees]))
ORDER BY payments.ClaimID DESC;

Note the direct link to [Forms]![GPSOLO]![CboEmployees], this eliminates the need to set the rowsource in your code for the Employee. So you can totaly remove the line, where you assign the rowsource:
Code:
 Me.CboPaymentDate.RowSource = "Select [Session Date] From QryHistory Where [GPID] =" & Me.CboEmployees & " Order By [Session Date] DESC;"

Lastly can you please attach your DB here? I see no harm in it beeing public and it is small enough....
 

Users who are viewing this thread

Back
Top Bottom