473,386 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

user input to query

Hi,

I have a report that is a based on a query.
One of the fields in the query is "time of sale", which is a date
field that holds the sales dates (day,month,year).
I want to use that field as a month criteria in the query, so the report
will print only records that holds a specific month in that field.
How can I prompt the user to enter the month and pass it to the query ?

Thanks!
Nov 12 '05 #1
2 6837
In message <ne********************@lnews.actcom.co.il>, Marius Kaizerman
<ma****@kaizerman.org> writes
Hi,

I have a report that is a based on a query.
One of the fields in the query is "time of sale", which is a date
field that holds the sales dates (day,month,year).
I want to use that field as a month criteria in the query, so the report
will print only records that holds a specific month in that field.
How can I prompt the user to enter the month and pass it to the query ?


The simple way is to include an extra field in the query. If you call it
[Sales Month] then Access will prompt for a value whenever the query is
executed. If you trust your users to enter the right data every time
then this is enough. More realistically you need to put an extra field
on a form and have the users enter the month into it. You may be able to
give it a sensible default value if, for instance, users usually run
reports for the previous month.

You should add some code to make sure that when the user enters a value
they enter one that makes sense.

Code like this may do what you want: usual disclaimers apply.

----------------------8<-------------------------------------8<----------
-------------------------

Private Sub PrintThis_Click()
On Error GoTo Err_PrintThis_Click
RunCommand acCmdSaveRecord
Dim stDocName, WhereString As String
WhereString = "History.ID = " & Me.ID

stDocName = "Single Linked History Detail"
DoCmd.OpenReport stDocName, acNormal, "History", WhereString

Exit_PrintThis_Click:
Exit Sub

Err_PrintThis_Click:
MsgBox Err.Description
Resume Exit_PrintThis_Click
End Sub

--
Bernard Peek
London, UK. DBA, Manager, Trainer & Author. Will work for money.

Nov 12 '05 #2
1) Insert in criteria for that field something like:
[What's the month ? ] as a data-entry point
2) I suppose <time of sales> is an alias for something like <timesales>
that's the real name of your field
Replace in the query your field with: Times of sales:
Int(Format([timesales];"mm")) that filters it only for month.

Bye, Marco.

"Marius Kaizerman" <ma****@kaizerman.org> ha scritto nel messaggio
news:ne********************@lnews.actcom.co.il...
Hi,

I have a report that is a based on a query.
One of the fields in the query is "time of sale", which is a date
field that holds the sales dates (day,month,year).
I want to use that field as a month criteria in the query, so the report
will print only records that holds a specific month in that field.
How can I prompt the user to enter the month and pass it to the query ?

Thanks!

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Stan Cook | last post by:
How do you write a query which will stop ans wait for user input? Stan
8
by: rgonzale6 | last post by:
Hello. I'm using SQL query analyzer to run some queries against an SQL2000 DB. Unfortunately, my previous SQL experience is some Oralce SQL I took in school. To put it simply, I'm trying to...
1
by: Steven Canfield | last post by:
<html> <head> <script type="text/javascript"> function submit() { var queryField = document.getElementById("queryField"); document.location.href = document.location.href + "/query/" +...
3
by: RC | last post by:
I can't quite grasp the concept of creating custom reports depending upon what options a user picks on a Form. For example, the user clicks on a "Print Reports" button and a Form pops up. On the...
2
by: underground | last post by:
Hi, everyone I've been trying to figure out a way for a user to update there information. I'm using sections to identify the specific user..Here is the form <? include("include/session.php");...
4
waynetheengineer
by: waynetheengineer | last post by:
Hi, I was wondering if anyone had any suggestions on my database: I have a form that accepts user input into a single text box. When the OK button is hit, a query should search for all records...
1
by: Barb.Richards | last post by:
I have created an append query that pulls information from one database, and will append the selected information into a new table. The fields are setup like 'number' 'category' 'code' 'shares' and...
82
by: happyse27 | last post by:
Hi All, I modified the user registration script, but not sure how to make it check for each variable in terms of preventing junk registration and invalid characters? Two codes below : a)...
9
by: happyse27 | last post by:
Hi All, In perl script(item b below) where we check if html registration form are filled in properly without blank with the necessary fields, how to prompt users that the field are incomplete...
3
by: swetha123 | last post by:
hello, I don't know how to use cookies please help me in this I am using the dream weaver cs4 I designed the navigation bar to my page using dream weaver cs4 navigation bar contains...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.