Extracting currenty month / Access97

A

Abay

I have a form that displays filtered info from a table .. part of the filter
is the current "system month". My question is how do I code this ..
currently I have the month "hard coded" but would like to be able to
automatically extract the data without having to change the code each month.
My code is as follows:

Private Sub Form_Load()
If FilterOptions = 1 Then
Me.Filter = "servicedatetime like '10/*/04' and itemtype like
'contract*' and showcon = 'y'"
Me.FilterOn = True
End If
End Sub

I know I can get "to-days date" using date(), don't know how to extract part
of it. Have looked at using the Datepart function, (looked it up in Help)
but don't see how I can apply it here .. any suggestions would be much
appreciated, also any suggestions on books I can buy and educate myself more
on VB for access would be much appreciated .. I currently have "Teach
yourself VB for Access" which is great for the basics and that's about all
....thanks in advance.

Abay
 
D

Douglas J. Steele

Assuming servicedatetime is a date field (as opposed to text), try:

Me.Filter = "Format(servicedatetime, ""yyyymm"") = Format(Date(),
""yyyymm"") and itemtype like
'contract*' and showcon = 'y'"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Extract current month 1
Excel Message box with days of month & date. 1
Extracting Month and year 1
Filtering by month 1
match 2
Extract filtered data 1
Access 2 Digit year in Access Text Box 3
Data extract after applying a filter 1

Top