473,386 Members | 1,726 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.

How do I pass variable value to the report that uses query

Hello,
I have a problem with opening the report using a variable from the access form.
Suppose I have a form with customer data - one of the fields is called "ClientID" and in the same databese I have a report that uses a query that one of the parameters is "Like [Enter ClientID:]". When report starts the user is prompted: "Enter ClientID:" If user puts from keyboard "ClientID" the command shows a report for the entered value.
I would like to ask if there is a way for the report/query to take the "ClientID" from the form with customer data.
Thanks in advance for help.
Sep 1 '15 #1
2 970
Seth Schrock
2,965 Expert 2GB
Replace the [Enter ClientID:] in the query with Forms!Form_Name_Here!ClientID
Sep 1 '15 #2
jforbes
1,107 Expert 1GB
I would remove the Query Parameter so that if the Report is opened, it will show reports for every Client in the Database. Then when calling the OpenForm in VBA, supply the Where Condition to limit the Report to only the Client that you want.

Here is a real world example:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdQuotePreview_Click()
  2.     Dim sQuoteNumber As String    
  3.     sQuoteNumber = Nz(Me!QuoteNumber, "")   
  4.     If Len(sQuoteNumber) > 0 Then DoCmd.OpenReport "rptQuote", acViewPreview, , "QuoteNumber='" & Me!QuoteNumber & "'"
  5. End Sub
Sep 1 '15 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Phin | last post by:
I need your HELP! I've seen all the posts on using Crystal Reports within vs.net (vb.net) and changing a SQL query at runtime. When I tried to pass in a dataset into the crystal report at...
2
by: MX1 | last post by:
HELP! I have a query that gets a few values from a form. The problem I'm having is a date field in the query. When I put the value in the criteria, it works fine. When I put the same value as...
5
by: GB | last post by:
Hello: In my MS Access project I have two objects - my form and my report. I need to pass variable value from Command_click procedure of my form to Report_open procedure of my report. How can I...
1
by: csgraham74 | last post by:
Hi there, Having done much web development in recent times im a bit new to vb.net and uses of classes. Basically in my VB.Net code i call a connection to unidata then using this connection i...
2
by: jamesnkk | last post by:
I have no exactly idea how to pass a variable value from one form to another, How do I do it using, say in Form 1 using DoCmd.OpenForm like the below statement, correct me If I am wrong. FORM_1...
2
by: duancg | last post by:
Hi, I wonder if someone could help since I wasn't able to find the answer through search. I have a simple .aspx page that shows data from a database table, as a table in UI. Now the data uses...
5
by: techbuddha | last post by:
Hi new to the forum and visual basic. I am attempting to fix a migration of excel to access. The excel sheets where simple copied as is into access. for example one table lists the academic...
2
by: nickvans | last post by:
I have a question which I'm sure has a simple answer, but I'm pretty new at this. I have a database which contains several tables including tblModules and tblParts. tblParts stores module numbers...
1
by: shaiful | last post by:
Hi all, I have a problem with report in vba. I using vba report with access database. my query is: "select name, Roll, Adress from Stdinfo where id=Variable Here from form]" so how i can pass...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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...

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.