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
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

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
Avatar of ryanrh24
ryanrh24

ASKER

I have attached a screen shot of the Row Source I believe.
RowSource.png
need to see sample values.. better if you upload a copy of the db eith the form and relevant table and queries.
Avatar of ryanrh24
ryanrh24

ASKER

I'm not sure what you mean. Upload the entire database file?
yes, just remove sensitive info
Avatar of ryanrh24
ryanrh24

ASKER

Okay this should be it. Under the reports section is where I access it the most.
DB1.mdb
ok. what is the name of the form and the name of the combo box?
Avatar of ryanrh24
ryanrh24

ASKER

Form - frmFuelInvoiceReport
combo box - rdatepull

Also, this combo box is used in multiple forms for pulling all the different report types.
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of ryanrh24
ryanrh24

ASKER

That is great! Will I need to change this each month or is it set to automatically do that?
<Will I need to change this each month> NO
 or is it set to automatically do that? YES
Avatar of ryanrh24
ryanrh24

ASKER

How would you change the code so it would show one month previous to the current month every time?
change this

 iMonth = Month(Date)

to

 iMonth = Month(Date) -1
Avatar of ryanrh24
ryanrh24

ASKER

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
Avatar of ryanrh24
ryanrh24

ASKER

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
Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo