Solved

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

Posted on 2014-03-10
15
412 Views
Last Modified: 2014-03-18
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
0
Comment
Question by:ryanrh24
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 7
15 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39918634
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
 

Author Comment

by:ryanrh24
ID: 39918660
I have attached a screen shot of the Row Source I believe.
RowSource.png
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39918737
need to see sample values.. better if you upload a copy of the db eith the form and relevant table and queries.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:ryanrh24
ID: 39918866
I'm not sure what you mean. Upload the entire database file?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39918878
yes, just remove sensitive info
0
 

Author Comment

by:ryanrh24
ID: 39918907
Okay this should be it. Under the reports section is where I access it the most.
DB1.mdb
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39919004
ok. what is the name of the form and the name of the combo box?
0
 

Author Comment

by:ryanrh24
ID: 39919017
Form - frmFuelInvoiceReport
combo box - rdatepull

Also, this combo box is used in multiple forms for pulling all the different report types.
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 39919030
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
 

Author Comment

by:ryanrh24
ID: 39919053
That is great! Will I need to change this each month or is it set to automatically do that?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39919132
<Will I need to change this each month> NO
 or is it set to automatically do that? YES
0
 

Author Comment

by:ryanrh24
ID: 39929675
How would you change the code so it would show one month previous to the current month every time?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39929797
change this

 iMonth = Month(Date)

to

 iMonth = Month(Date) -1
0
 

Author Comment

by:ryanrh24
ID: 39930114
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
 

Author Comment

by:ryanrh24
ID: 39937487
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

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question