Combo Boxes for Dates

Try using

CInt(Me.cboYear)
 
That hasn't worked, thanks for the suggestion.

When you select a year and then press september it brings up a box asking for the value of cboYear.
 
Anyone have an idea for this?

The CInt(Me.cboYear) didn't work (not exactly clear above). I don't know what else to try.
 
That hasn't worked, thanks for the suggestion.

When you select a year and then press september it brings up a box asking for the value of cboYear.

What's the ROW SOURCE of cboYear?
 
Value List:

2010;2011;2012;2013;2014;2015;2016;2017;2018;2019;2020
Bound Column = 1
Limit to List = Yes

When you press September (my test button) is asks for the value of cboYear, if you enter 2010 then it works perfectly. It just isn't reading the value of cboYear
 
Okay, so you've tried to do it like this:

DoCmd.ApplyFilter "", "[MOT Due] Between DateSerial(Me.cboYear, 9, 1) And DateSerial(Me.cboYear, 9 + 1, 0)"

and/or

DoCmd.ApplyFilter "", "[MOT Due] Between DateSerial(CInt(Me.cboYear), 9, 1) And DateSerial(CInt(Me.cboYear), 9 + 1, 0)"
 
I have previously tried both but have just tried again to be sure and neither have worked. Both methods bring up the box asking for the value of cboYear.

The only reference the combo box has to cboYear is set under the "other" tab and "name" value of cboYear.
 
Can you post the database? Even if you clear out the records.
 
The combo has to be concatenated into the string, like

"[MOT Due] Between DateSerial(CInt(" & Me.cboYear & "...

You might get away not doing that by using the full form reference, I'm not sure. But Me is only valid within VBA, and the string isn't being evaluated by VBA.
 
The combo has to be concatenated into the string, like

"[MOT Due] Between DateSerial(CInt(" & Me.cboYear & "...

You might get away not doing that by using the full form reference, I'm not sure. But Me is only valid within VBA, and the string isn't being evaluated by VBA.

Yes, I forgot about the concatenation part. But the Me part is valid IF and ONLY IF (as you specified) it is OUTSIDE the quotes.

I must be having a mental meltdown or something to have missed that obvious one. :confused::eek::(
 
I think I need a vacation....







Actually, I do - I do need a vacation....






But I can't have one.....






Bummer.....
 
The information in the database is only dummy stuff that I've typed in through testing various things. I can't upload it onto the forum.

Thanks for all your help with this
 
Last edited:
The information in the database is only dummy stuff that I've typed in through testing various things. I can't upload it onto the forum, so have uploaded to my domain.

http://www.linusit.co.uk/automotive.mdb

Thanks for all your help with this

I can't download from work as the mdb files are blocked for download (need to be zipped I believe).

Anyway, it is irrelevant now because Paul gave the correct answer:

DoCmd.ApplyFilter "", "[MOT Due] Between DateSerial(" & Me.cboYear & ", 9, 1) And DateSerial(" & Me.cboYear & ", 9 + 1, 0)"
 
Excellent, I have applied that code and it works great, thank you!
 
Last edited:

Users who are viewing this thread

Back
Top Bottom