Solved

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

Posted on 2014-03-10
15
409 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 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
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…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

856 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