Solved

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

Posted on 2014-03-10
15
405 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

863 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