Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

having a problem with filtering code...

Status
Not open for further replies.

InsaneMember

Technical User
Apr 24, 2002
16
0
0
US
it has to do with the employee hours form. it saying something about an incompatible data type.

i have the database, if you could help, e-mail me at: 123@smsos.com

thanks!
 
Hi,

Why don't you post the relevant code wheer the error is occuring? It sounds like a type mismatch so check the datatypes of your fields and the values you are trying to assign into them. Also, be on the lookout for NULL values.

Have a good one!
BK
 
here goes..

there are 3 combo boxes, one for month, payperiod, and year. it's supposed to look for payroll stuff during the payperiod.





Option Compare Database
Dim begDate, lasDate As Date

Private Sub cmbMth_AfterUpdate()
FilterMonth
End Sub
Private Sub cmbyear_afterupdate()
FilterMonth
End Sub
Private Sub cmbPay_afterupdate()
If cmbPay.Value = "1-15" Then
begDate = 1
lasDate = 15
End If

If cmbPay.Value = "16-EOM" Then
begDate = 16
lasDate = Day(DateSerial(cmbYear.Value, Month(cmbMth.Value) + 1, 0))
End If
End Sub
Private Sub form_initialize()
cmbMth.Value = Month(Date)
begDate = 1
lasDate = 15
cmbYear.Value = year(Date)
End Sub
Function FilterMonth()
Dim PayPeriod As Date
PayPeriodstart = DateValue(cmbMth.Value + " " + begDate + ", " + cmbYear.Value)
PayPeriodEnd = DateValue(cmbMth.Value + " " + endDate + ", " + cmbYear.Value)

[Calc Hours subform].Filter = PayPeriodstart <= [Calc Hours subform].Form![Date] And [Calc Hours subform].Form![Date] <= PayPeriodEnd
End Function
 
I think the filter needs to receive a string.
[Calc Hours subform].Filter = &quot;PayPeriodstart <= #&quot; & [Calc Hours subform].Form![Date] & &quot;# And #&quot; & [Calc Hours subform].Form![Date] & &quot;# <= PayPeriodEnd&quot;
or
[Calc Hours subform].Filter = &quot;PayPeriodstart <= [Calc Hours subform].Form![Date] And [Calc Hours subform].Form![Date] <= PayPeriodEnd&quot;
One of these ought to do it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top