Avatar of ryanrh24
ryanrh24 asked on

Access 2010 How to change default starting point in a drop down box

Hi. In Access 2010 I have some reports that are sorted by month. I would like to be able to change the starting point each month when I click the drop down box so I don't have to scroll from 2002 to the current year to find the month. It's not a huge deal, but it would be nice if I didn't have to do that extra step. Where would I go to adjust this setting. Also, it is important that the previous months be viewable so I could scroll back if I needed to do so. I hope this makes sense. Thank you.
reportsdropdown.png
Microsoft Access

Avatar of undefined
Last Comment
ryanrh24

8/22/2022 - Mon
Rey Obrero (Capricorn1)

what is the rowsource of the combobox? post it here

you can use this codes in the enter event of the combo box

me.combo0.dropdown
me.combo0.value=dateserial(year(date()),month(date())+1,0)


off course that will vary depending on the rowsource of your combo box
ASKER
ryanrh24

I have attached a screen shot of the Row Source I believe.
RowSource.png
Rey Obrero (Capricorn1)

need to see sample values.. better if you upload a copy of the db eith the form and relevant table and queries.
Your help has saved me hundreds of hours of internet surfing.
fblack61
ASKER
ryanrh24

I'm not sure what you mean. Upload the entire database file?
Rey Obrero (Capricorn1)

yes, just remove sensitive info
ASKER
ryanrh24

Okay this should be it. Under the reports section is where I access it the most.
DB1.mdb
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Rey Obrero (Capricorn1)

ok. what is the name of the form and the name of the combo box?
ASKER
ryanrh24

Form - frmFuelInvoiceReport
combo box - rdatepull

Also, this combo box is used in multiple forms for pulling all the different report types.
ASKER CERTIFIED SOLUTION
Rey Obrero (Capricorn1)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
ryanrh24

That is great! Will I need to change this each month or is it set to automatically do that?
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Rey Obrero (Capricorn1)

<Will I need to change this each month> NO
 or is it set to automatically do that? YES
ASKER
ryanrh24

How would you change the code so it would show one month previous to the current month every time?
Rey Obrero (Capricorn1)

change this

 iMonth = Month(Date)

to

 iMonth = Month(Date) -1
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
ryanrh24

Thank you! I am receiving a new error. I have attached screen shots.
The main issue is whenever I use the Enter key to select the date from the rdatepull (Month) drop down box, it won't process the same way as when I click the date with my mouse, thus making the report unable to load. Is there a piece of code I can place in there to correct this?
dateError1.png
dateDebugError1a.png
dateError2.png
dateDebugError2a.png
ASKER
ryanrh24

I still haven't been able to figure this out. I cannot make tabbing over and hitting enter do the same thing as clicking on the date with the mouse. It may have something to do with this macro I attached. Any help would be much appreciated! The first attachment is after the rdatepull code was added. The second is before, when the enter button worked.
rdatepulladded.png
macrodatepull1.png