Solved

msaccess 2007 creating a "variable"

Posted on 2013-02-05
5
231 Views
Last Modified: 2013-02-05
Hi.

I have a database with a lot of dates in it and I would like to create an input form that has a field or variable called date which I enter and then a query will display all the records in my table corresponding to that date. I know I could do this in a report but the query I will make will also update the date by 7 days. How do I get from the input form to the report to print out a simple query like this.?
0
Comment
Question by:PawloA
[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
  • 3
  • 2
5 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38856768
Not sure about the "update" part, ...but to have a form variable used as a query criteria you can:
1. Create a public Variable in a module:
Public dtmYourDate as date

2. Create a public function to retrieve this date:
Public Function GetYourDate() as date
    GetYourDate=dtmYourDate
end function

Then create your query to look at this variable as the criteria:
SELECT....
FROM...
WHERE Yourdate=GetYourDate()

Then assign the form control value to the variable
Create a button to open the query
On the click event of the button, use code like this:
dtmYourDate =txtYourDate
Docmd.OpenQuery "YourQuery"

;-)

JeffCoachman
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 500 total points
ID: 38856822
like so...
Database87.mdb
0
 
LVL 1

Author Comment

by:PawloA
ID: 38856860
How would I do this in Access. do I go to the visual basic. Sorry I am pretty new to msaccess and I have to take a crash course on this. Any help would be appreachiated.
0
 
LVL 1

Author Closing Comment

by:PawloA
ID: 38856933
Thanks. This is exactly what I am looking for.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38857024
;-)
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
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…

696 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