[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 2014-03-10
15
Medium Priority
?
425 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
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 

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 2000 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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

656 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