473,626 Members | 3,389 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to insert a default parameter value in VB OR use another function in report query

1 New Member
Hi,

I searched online for some similar issues that I am facing but was not able come up with anything. I am fairly new with Access (2 months experience) and I am trying to remove a message stating, ENTER PARAMETER VALUE when I am generating a report. I know that the culprit lies in the query stored in the report. I have entered data in the CRITERIA (entered forms!frmproduc ts!lngproductID ) window and OR (entered forms!frmprodus er!lngproductID ) window. The problem is that if one is filled with a value, the other one asks for a value through an ENTER PARAMETER VALUE window.

I would like to avoid using two reports (one for each form) to solve the problem by only have one criteria filled in each report query.

There are two ways I could think of to solve the problem:

First way: using VB to detect and automatically fill in a value of '0' (zero) when the form frmproducts is closed on the same computer.

I have two forms that print to the exact same report:
1) forms!frmproduc ts!lngproductID - for administrator
2) forms!frmprodus er!lngproductID - for product manager (limited data changes and access).

Below is the current VB code from print command button on the form, FRMPRODUSER.

*** BEGIN VB CODE *****
Expand|Select|Wrap|Line Numbers
  1. Private Sub Preview_Click()
  2. On Error GoTo Err_Preview_Click
  3.     DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
  4.     If IsNull(Me![LngProductID]) Then
  5.         MsgBox "Please enter the product data in the form."
  6.     Else
  7.         MsgBox "Opening default label, 4x3, to preview for printing."
  8.         DoCmd.OpenReport "rpt4x3StdLabel", acPreview, , "Forms![frmProdUser].[lngProductID]=" & Me![lngProductID]
  9.     End If
  10.  
  11. Exit_Preview_Click:
  12.     Exit Sub
  13.  
  14. Err_Preview_Click:
  15.     If Err <> 2501 Then
  16.         MsgBox Err.DESCRIPTION
  17.     End If
  18.     Resume Exit_Preview_Click
  19. End Sub
*** END VB CODE ***

Secondly, is there a function that would be satisfied if only one form forwards the data via VB? I would be entering the parameters in teh CRITERIA box in the report query.

I hope that I am making sense. If not, feel free to clarify. I am self-taught on Access (by way of books and reading online), so I am not quite familiar with the common terms you all use.

Any help would be greatly appreciated.

-Eric
Dec 5 '06 #1
2 5421
NeoPa
32,568 Recognized Expert Moderator MVP
This is probably easier than you think.
But, to guide you through it I'll need the SQL of the query your report uses.
I think it's a great idea to use the same report flexibly - I try to do that all the time myself.
Your stLinkCriteria is definitely wrong!
What it should be I can only tell with access to the reports query SQL.
In outline, though, it should say something like :
Expand|Select|Wrap|Line Numbers
  1. "([ProductID]=" & Me.[lngProductID] & ")"
Assuming the query has a field being filtered called [ProductID].
Assuming also (from name lngProductID) that field is numeric.
Dec 5 '06 #2
NeoPa
32,568 Recognized Expert Moderator MVP
I'm not sure what your second question was about.
If it still needs an answer then ask me again (perhaps using different wording).
Dec 5 '06 #3

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

Similar topics

3
2890
by: Mike | last post by:
If possible, how do I use a function to create a default parameter value? The following gives me an "unexpected '(', expecting ')'" error, which makes sense. function DisplayInfo($ID, $startdate=date("Ydm"), $numdays=7) { ...function here... }
12
12692
by: earl | last post by:
class temp { public: temp(); foo(char, char, char*); private: char matrix; }; temp::foo(char p, char o, char m = matrix )
3
2746
by: Capstar | last post by:
Hi NG, I am trying to get the attached piece of code to work, but I can't figure out what I'm doing wrong. To me it seems that when I don't pass an argument to x::do_something, it should use the default value, which is always_true(). but gcc says: no matching function for call to `x::do_something()' and msvs says: could not deduce template argument for '_Tp'
4
26451
by: | last post by:
I there a way to provide a default value for a parameter in a method? E.g. private void somemethod(string whatever, string whatever2 = "someval")
1
2105
by: ShadesOfGrey | last post by:
Hello again. Thanks to Gord, I have this cool query that puts my student attendance records in a calendar format in Access 2003. PARAMETERS Text ( 255 ), IEEEDouble; TRANSFORM First(IIf(=1,"S","I")) AS Type SELECT Year() AS , Month() AS , & " " & AS Name FROM Member_List_tbl INNER JOIN Attendance_tbl ON Member_List_tbl. = Attendance_tbl. WHERE ((( & " " & )=) AND ((DatePart("yyyy",))=))
4
9175
by: Chris | last post by:
Suppose I have the following function signature void foo( Bar &myBar); and I want myBar to be an optional parameter, is there a way to do the logical equivalent of void foo( Bar &myBar = myBar() ) when passing by reference? Every method I've tried gives me syntax
0
1725
by: Homer J. Simpson | last post by:
When I try to use the following: <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:csToolbar %>" SelectCommand="spGetValuesForDateRange" SelectCommandType="StoredProcedure"> <SelectParameters> <asp:Parameter DefaultValue="<%= DateTime.MinValue %>" Name="FIRSTDAY" Type="DateTime" /> <asp:Parameter DefaultValue="<%= DateTime.MaxValue %>" Name="LASTDAY" Type="DateTime" />
1
1371
by: ncsthbell | last post by:
I created a form "frmReportParms", on this form I have created a combo box box which lists 'divisions'. I put code behind the 'after click' event on the combo box to move the value selected to a variable 'txtDivision'. I also have this variable defined on the form but invisible. The division column in my report query has '!!' as the criteria. When I run the report, I get a message box that prompts me for this value. When I enter a value...
0
1312
by: rose mary | last post by:
MY FOLLOWING CODE IS NOT INSERTING VALUES IN MS-ACCESS DB:- class page { void SUBMIT(String origin) { String driver = "sun.jdbc.odbc.JdbcOdbcDriver"; String url = "jdbc:odbc:RUCHI"; Connection con=DriverManager.getConnection(url); Statement st= con.createStatement();
0
8713
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8644
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8370
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8514
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7206
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5579
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4208
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1817
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1516
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.