473,503 Members | 5,004 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

1 New Member
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 972
Seth Schrock
2,965 Recognized Expert Specialist
Replace the [Enter ClientID:] in the query with Forms!Form_Name_Here!ClientID
Sep 1 '15 #2
jforbes
1,107 Recognized Expert Top Contributor
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
3966
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
2050
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
7068
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
1060
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
3911
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
3375
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
5735
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
1533
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
1820
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
7188
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7063
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
7258
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7313
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...
1
6970
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7441
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5558
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4987
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
1489
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.