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
ryanrh24Asked:
Who is Participating?
 
Rey Obrero (Capricorn1)Connect With a Mentor Commented:
place this codes in the enter event of the combo box


Private Sub rdatepull_Enter()
me.rdatepull.dropdown
Dim iYear As Integer, iMonth As Integer
iYear = Year(Date): iMonth = Month(Date)
Me.rdatepull.Value = DLookup("iddate", "QRY_datepull", "mmonth=" & iMonth & " and myear=" & iYear)
End Sub
0
 
Rey Obrero (Capricorn1)Commented:
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
0
 
ryanrh24Author Commented:
I have attached a screen shot of the Row Source I believe.
RowSource.png
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
Rey Obrero (Capricorn1)Commented:
need to see sample values.. better if you upload a copy of the db eith the form and relevant table and queries.
0
 
ryanrh24Author Commented:
I'm not sure what you mean. Upload the entire database file?
0
 
Rey Obrero (Capricorn1)Commented:
yes, just remove sensitive info
0
 
ryanrh24Author Commented:
Okay this should be it. Under the reports section is where I access it the most.
DB1.mdb
0
 
Rey Obrero (Capricorn1)Commented:
ok. what is the name of the form and the name of the combo box?
0
 
ryanrh24Author Commented:
Form - frmFuelInvoiceReport
combo box - rdatepull

Also, this combo box is used in multiple forms for pulling all the different report types.
0
 
ryanrh24Author Commented:
That is great! Will I need to change this each month or is it set to automatically do that?
0
 
Rey Obrero (Capricorn1)Commented:
<Will I need to change this each month> NO
 or is it set to automatically do that? YES
0
 
ryanrh24Author Commented:
How would you change the code so it would show one month previous to the current month every time?
0
 
Rey Obrero (Capricorn1)Commented:
change this

 iMonth = Month(Date)

to

 iMonth = Month(Date) -1
0
 
ryanrh24Author Commented:
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
0
 
ryanrh24Author Commented:
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.