[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 272
  • Last Modified:

How do I store an Access parameter when I'm first asked to enter the value?

Hi everyone,

I currently have an Access database that asks for a RUN_DATE parameter where I'm required to input a run date.  My problem is that I don't want to have to continually put that date in when I run a report or look at a query.  Is there any way that I can have access save that value or that I can define my RUN_DATE parameter to a fixed value for the time I want to run it and then I just change that field as I want different dates?

I hope I was somewhat clear on what I want to do.

2 Solutions
Rey Obrero (Capricorn1)Commented:
use a form to enter the date.
revised the query criteria to refer to the form's entered date value.
I would list all your date choices in a combo box - then on making a selection, the click event of the combo box fires and will execute the code according.

If you have a saved query qryFromCombo with SQL along the lines of:

SELECT * FROM myTable WHERE myDate = Forms!myForm!myCombo

In the Click event of the combo:

Private Sub myCombo_Click()
  DoCmd.OpenQuery "qryFromCombo"
End Sub

Armen Stein - Microsoft Access MVP since 2006Commented:
One way to have a report prompt the user for criteria before it runs is to open a form from the report's Open event.  Open the form in Dialog mode so that the report waits for the form to be closed or hidden before it proceeds.  That way you can collect criteria from the user and build a Where clause for the report.  It also means that you can call the report directly - you don't need to call it from a form.  And the selection form is reusable - it can be called from multiple reports if they need the same criteria.

Also - since the criteria form is hidden, not closed, each time you run the report in the same session, it remembers your previous criteria.

I've posted examples of this technique on our free J Street Downloads page at http://www.JStreetTech.com/downloads.
See "Report Selection Techniques".

Anthony6890Author Commented:
Hey everyone,

Thanks for getting back to me.  Sorry it took so long, I was away for the holiday weekend.

I was able to get it work using the forms as suggested above.

Thanks again!


Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now