Solved

msaccess 2007 creating a "variable"

Posted on 2013-02-05
5
230 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
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 …

726 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