Month & Year Only in Combo Boxes

skilche1

Registered User.
Local time
Today, 15:42
Joined
Apr 29, 2003
Messages
226
I am trying to select the month and year from a combo box on a form taken from the tlbData table, which the field is formated with {short date} containing daily entries (ie: 1/29/2009, 1/30/2009, and so on).

I am working on retrieving data that fits within the Month's search criteria.

Can someone point me int he right direction? Can't seem to find help that works.

Thanks. :D
 
you might to add .Text:
Code:
    Me.Textbox1 = DatePart("yyyy", Me.DateCbobox[B].Text[/B]) 'year
    Me.Textbox2 = DatePart("m", Me.DateCbobox[B].Text[/B]) 'month
 
you might to add .Text:
Code:
    Me.Textbox1 = DatePart("yyyy", Me.DateCbobox[B].Text[/B]) 'year
    Me.Textbox2 = DatePart("m", Me.DateCbobox[B].Text[/B]) 'month

hmmm, not what I was expecting. How do I implement this?

Thanks
 
er, i'm not exactly sure what you're implementing. i thought you just couldn't extract parts of a date from a value in a combobox. i see you want to search for something but i'm not sure what you're up to there.
 
er, i'm not exactly sure what you're implementing. i thought you just couldn't extract parts of a date from a value in a combobox. i see you want to search for something but i'm not sure what you're up to there.

OK, perhaps I wasn't as clear as I should have been. Right now, we are storing data by date {Field Format Type: short Date} (ex: 1/29/2009, 1/30/2009, ect, ect, ect....). In the form, I want to perform a search, but not by {sort date} to {short date} (that's easy to perform), rather I want to use a single combo box with the Month and Year (EX: February 2009) to pull up records.

Does this help? :confused:

Thanks again wazz
 
query for your cbobox (qryListDatesMonthYear, or sim.):
Code:
SELECT Format([YourDateField],"mmmm") & " " & DatePart("yyyy",[YourDateField]) AS MonthYear
FROM tblYourTable
GROUP BY Format([YourDateField],"mmmm") & " " & DatePart("yyyy",[YourDateField])
ORDER BY Format([YourDateField],"mmmm") & " " & DatePart("yyyy",[YourDateField]);
query for the form (qryGetDatesByMonthAndYear, or sim):
Code:
SELECT tblYourTable.YourDateField
FROM tblYourTable
WHERE (((Month([YourDateField]))=Month([Forms]![YourForm]![YourCombobox])) AND ((Year([YourDateField]))=Year([Forms]![YourForm]![YourCombobox])));
put those queries into two new saved queries (View-Sql).

your combobox_afterupdate event:
Me.RecordSource = "qryGetDatesByMonthAndYear"
 

Users who are viewing this thread

Back
Top Bottom