Solved

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

Posted on 2014-03-10
15
400 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
  • 8
  • 7
15 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
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 119

Expert Comment

by:Rey Obrero
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
 

Author Comment

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

Expert Comment

by:Rey Obrero
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 119

Expert Comment

by:Rey Obrero
ID: 39919004
ok. what is the name of the form and the name of the combo box?
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

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 119

Accepted Solution

by:
Rey Obrero 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 119

Expert Comment

by:Rey Obrero
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 119

Expert Comment

by:Rey Obrero
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

762 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now