473,749 Members | 2,626 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

OpenReport through code instead of a macro

3 New Member
Since I'm new I like using macro's over code, but coding allows me to do so much more. I'm still learning.

I have a macro for a button that opens a report with a long "Where Condition" I understand that the macro does not support as many characters as code does in the "where condition"

Heres an example of what I'm trying to do with the Macro (as one line without returns)

([ReceiveType] Like [Forms]![MakeReport]![Combo27]) And
([CompanyName] Like [Forms]![MakeReport]![Combo29]) And
([DateReceived] Like [Forms]![MakeReport]![Combo37]) And
([ReceiveRef] Like [Forms]![MakeReport]![Combo33]) And
([NewService] Like [Forms]![MakeReport]![Combo43]) And
([BoardType] Like [Forms]![MakeReport]![Combo31])

Can someone help me with this code?

All help is appreciated. Thanks
Aug 22 '08 #1
1 1534
hyperpau
184 Recognized Expert New Member
Apply this code on the On-Click event of your button.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdYourButton_Click()
  2. Dim stCriteria as String
  3.  
  4. stCriteria = "[ReceiveType] ='" & Me![Combo27] & "' And [CompanyName] ='" & Me![Combo29] & _
  5. "' And [DateReceived] ='" & Me![Combo37] & "' And [ReceiveRef] ='" &  Me![Combo33] & _
  6. "' And [NewService] ='" & Me![Combo43] & "' And [BoardType] = '" & Me![Combo31] & "'"
  7.  
  8. DoCmd.OpenReport "rptYourReport", acPreview, ,  stCriteria , acDialog 
  9. End Sub

Note: This should work assuming all of your comboboxes are bound to a String field. If some of them are Numbers, you need to omit the singlequotes (').

Ex:
Expand|Select|Wrap|Line Numbers
  1. "[ReceiveType] =" & Me![Combo27] & "And ......
Instead of
Expand|Select|Wrap|Line Numbers
  1. "[ReceiveType] ='" & Me![Combo27] & "' And ......
Since I'm new I like using macro's over code, but coding allows me to do so much more. I'm still learning.

I have a macro for a button that opens a report with a long "Where Condition" I understand that the macro does not support as many characters as code does in the "where condition"

Heres an example of what I'm trying to do with the Macro (as one line without returns)

([ReceiveType] Like [Forms]![MakeReport]![Combo27]) And
([CompanyName] Like [Forms]![MakeReport]![Combo29]) And
([DateReceived] Like [Forms]![MakeReport]![Combo37]) And
([ReceiveRef] Like [Forms]![MakeReport]![Combo33]) And
([NewService] Like [Forms]![MakeReport]![Combo43]) And
([BoardType] Like [Forms]![MakeReport]![Combo31])

Can someone help me with this code?

All help is appreciated. Thanks
Aug 22 '08 #2

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

Similar topics

3
12998
by: Aaron | last post by:
Hello, I'm trying to limit a report to a list of parameters that I pass in. The report and the underlying query both use the column FirstName. Whenever I try to limit the FirstName in via the "Where" clause, I get prompted to input the FirstName parameter, even though I'm passing it in via OpenReport The syntax I tried using:
0
1944
by: Jay Bienvenu | last post by:
I'm having a very strange problem that currently defies explanation. I use the code below to send a status report to a client. The intent is to send the user the report via fax using WinFax and/or email it using Outlook. The problem is that after executing the DoCmd.OpenReport command (fax) or DoCmd.SendObject command (email), the code simply stops running. No error message, no indication that there is a logical reason for this code to...
1
3874
by: Andrew | last post by:
Hi All: I am using Access2000 and I find that the command to open an Access report in preview mode is very slow: DoCmd.OpenReport rptABC, acViewPreview, "", "" The scenario is this: - The following codes are written in the VB Applcation. - Prior to opening the report, I set its recordsource with a sql: ..Reports!rptABC.RecordSource = sSql. The sSql searches for a specific
3
2515
by: Blah | last post by:
Hello, I'm trying to use the where clause in OpenReport to limit the data return on the subreport. Is there a way to do it using that method or OpenReport only work with the report you're opening? Thanks
6
16449
by: Xing Xu | last post by:
Hi guiders, sorry , since I don't know which group suit for this question,I just post this question at these group. As we know , we can get the run-time call graph by some proved tools . now I have a problem about the extract call graph from statice C source code , not from binary. I have try to use cscope and write some perl script for it .
1
4775
by: Jimmy Stewart | last post by:
I have a continuous form with a list of items from a table. One of the fields in the table is "print". this allows the user to select items from the list on the form for printing in a report. on that form i have a button with the following onclick event: DoCmd.OpenReport "rptCustomerReport", acViewPreview, , "Print = True" This opens the report "rptCustomerReport" and shows all of the records that the user had checked of on the form....
232
13319
by: robert maas, see http://tinyurl.com/uh3t | last post by:
I'm working on examples of programming in several languages, all (except PHP) running under CGI so that I can show both the source files and the actually running of the examples online. The first set of examples, after decoding the HTML FORM contents, merely verifies the text within a field to make sure it is a valid representation of an integer, without any junk thrown in, i.e. it must satisfy the regular expression: ^ *?+ *$ If the...
36
2554
by: sh.vipin | last post by:
how to make large macro paste the code as it is Problem Explanation '-- For example in the program below /* a.c - starts here */ #define DECL_VARS() \ unsigned int a0;\ unsigned int a1;\ unsigned int a2;\
4
6675
by: gazza10001 | last post by:
Hi i hope you can help my company uses access and has modified for its needs usually what happens is you serach for the invoice by its number and then it brings all the information up such as entry fields and so there is a button you press which then takes to through to a print preview of the invoice and you print out the invoice but recent ly this message ahs started appearing and does not allow you to view the print preview of the invoice...
0
8833
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9568
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
9389
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...
0
9256
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
8257
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
6079
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
4709
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3320
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 we have to send another system
2
2794
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.