473,395 Members | 1,401 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,395 software developers and data experts.

How do I pass a parameter in VB from a form to a query used in OpenReport?

I have the login name on my form, Ulogin. The Report I call with OpenReport (from VB) uses a parameter, ulog, for the query it based upon. I pass Ulogin in a DOcmd.OpenReport using the where clause Ulog = ULogin. My report still prompts me for Ulog. I want to pass the login value to the parameter in the report such that no dialog box is displayed and the report runs automatically. What is the correct syntax for this or do I need to do this differently?
Thank you
Oct 20 '10 #1
5 2822
I tried loading the parameter value in the OpenArgs portion of the OpenReport. I checked it in Debug and it was correct. I loaded the correct value into the parameter value in the Open event for the report. Why does the parameter dialog box continue to prompt me for the login name - even though I successfully loaded it in the open event? My VB code said: ulog = Me.OpenArgs. Do I need to load it differently if it is a parameter?
Thank you for your help
Oct 20 '10 #2
ADezii
8,834 Expert 8TB
You can specify the Criteria in the Where Argument of the OpenReport Method, as in:
Expand|Select|Wrap|Line Numbers
  1. Dim strWhere As String
  2.  
  3. strWhere = "[LastName] = '" & Me![txtLastName] & "'"
  4.  
  5. DoCmd.OpenReport "Employees", acViewPreview, , strWhere, acWindowNormal
Oct 22 '10 #3
NeoPa
32,556 Expert Mod 16PB
AJ, if the query the report is run on has a parameter to be entered there is no way to pass that value to it in code.

To use code to provide the filtering the query itself must be redesigned. The query would be designed to view all records, then the opening would include a filter specification (actually called the WhereCondition parameter of the OpenReport() method) that ensured only the selected record was shown. Does that make it clearer?
Oct 22 '10 #4
Thank you. I figured out how to do it. The report was based on a query which contained the parameter. Instead of a parameter, I put where the query should find the value to use which is in a form. I used [Forms]![table]![field] and it worked great.
Oct 23 '10 #5
NeoPa
32,556 Expert Mod 16PB
That's certainly another way to redesign the query. Not my preference but Ibelieve it's popular amongst many.
Oct 25 '10 #6

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

Similar topics

7
by: Matt | last post by:
In ASP, when we pass data between pages, we usually pass by query string. If we pass data by query string, that means we need to use submit button, not by regular button, and the form will pass to...
0
by: Reggie | last post by:
Hi and TIA, I Have a query that uses a function for setting the Criteria. When I view the return value of the finction it appears to be exactly what I want for my criteria. The problem is if I...
7
by: Annelies | last post by:
I need to pass a parameter to the source query of a subform via vba. Any ideas on how to do that? (Actually I wanted to set the subform source to a query but I guess that isn't possible.. ) ...
4
by: Andy Davis | last post by:
I have developed a number of reports that are based on parameter queries where the user enters criteria such as a date range and a sales rep say. I want to be able to show a graphical picture in...
1
by: jindo | last post by:
Hi There! I must stresstest webservices. So I used parameter Like this 'http://aaa.bbb.ccc/services/BoardFD.asmx?op=showTable&IDno=96&tab=900'. but the parameters are not passed. how to pass...
2
by: Roger | last post by:
Anyone know how to pass a parameter to a query via a report in Access 2003?
1
by: Tarlanim | last post by:
Hi, i'm looking for a way to pass parameter from a HTML-File to a XML-File. In HTML-File i have a reference to XML-File and i want to use the parametre from the HTML-File in XML-File (Parameter...
0
by: bjswart | last post by:
Hello, Here is the query I'm trying to run from a C# Windows Program for a Login Form. SELECT CAST(DecryptByCert(Cert_ID('PassEncryption'), Password) AS NVARCHAR) AS Password, A.* FROM Test,...
2
by: de_ja | last post by:
Hi, If, for example an access database that concerns insurance claim investigations. The database comprises only one table containing data - investigation reference number, referral date,...
3
by: ofilha | last post by:
I am trying to pass a form as a parameter in a function. How can i do that? I have tried function( frm as Form) then on the calling routing i try to use private sub callingRoutine() Dim frm1...
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
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
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
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
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...

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.