Hi, i am trying to open a report based on values picked in a form but
get stuck with one of the values. I have a feeling it has to do with
the yes/no datatype but am not sure since I am quite new to access
VBA. I'm using Access2003
Below is my code extract. The tblWelderQualif ication.Stamped field is
a yes/no field, I want to show records that have a "TRUE" value when
the checkbox on the form is ticked. When I run the code, I get the
parameter value window popup asking for
"tblWelderQuali fication.Stampe d". If i type "True" then the report
works, if left blank it fails. I dont want to have to type anything
and would like it to work as it does for the other fields.
Any ideas??
stWhereClause = "(((tblWelderQu alification.[Test Number]) Like
IIf(Forms!frmTe stSubform!chkTe stNo=True,Forms !frmTestSubform !
TestNo,'*')) And " & _
"((tblWelde rs.[Welder ID]) Like IIf(Forms!frmTe stSubform!
chkWID=True,For ms!frmTestSubfo rm!wID,'*')) And " & _
"((tblWelderQua lification.[WPS No]) Like IIf(Forms!frmTe stSubform!
chkWPS=True,For ms!frmTestSubfo rm!subWPS,'*')) And " & _
"((tblWelderQua lification.Stam ped) Like IIf(Forms!frmTe stSubform!
chkCertified='T rue','True','*' )) And " & _
"((tblWelderQua lification.Proj ect) Like IIf(Forms!frmTe stSubform!
chkProject=True ,Forms!frmTestS ubform!txtProje ct,'*')))"
stDocName = "rptTest"
DoCmd.OpenRepor t stDocName, acPreview, , stWhereClause 3 6459 ru*******@gmail .com wrote:
Hi, i am trying to open a report based on values picked in a form but
get stuck with one of the values. I have a feeling it has to do with
the yes/no datatype but am not sure since I am quite new to access
VBA. I'm using Access2003
Below is my code extract. The tblWelderQualif ication.Stamped field is
a yes/no field, I want to show records that have a "TRUE" value when
the checkbox on the form is ticked. When I run the code, I get the
parameter value window popup asking for
"tblWelderQuali fication.Stampe d". If i type "True" then the report
works, if left blank it fails. I dont want to have to type anything
and would like it to work as it does for the other fields.
Any ideas??
stWhereClause = "(((tblWelderQu alification.[Test Number]) Like
IIf(Forms!frmTe stSubform!chkTe stNo=True,Forms !frmTestSubform !
TestNo,'*')) And " & _
"((tblWelde rs.[Welder ID]) Like IIf(Forms!frmTe stSubform!
chkWID=True,For ms!frmTestSubfo rm!wID,'*')) And " & _
"((tblWelderQua lification.[WPS No]) Like IIf(Forms!frmTe stSubform!
chkWPS=True,For ms!frmTestSubfo rm!subWPS,'*')) And " & _
"((tblWelderQua lification.Stam ped) Like IIf(Forms!frmTe stSubform!
chkCertified='T rue','True','*' )) And " & _
"((tblWelderQua lification.Proj ect) Like IIf(Forms!frmTe stSubform!
chkProject=True ,Forms!frmTestS ubform!txtProje ct,'*')))"
stDocName = "rptTest"
DoCmd.OpenRepor t stDocName, acPreview, , stWhereClause
A Yes/No actually stores -1 and 0 for True and False, but you can apply
criteria using True and False, but not 'True' and 'False' as you are.
Also, Like is only appropriate for text fields. For Yes/No, Numeric, and
Dates you should stick with "=".
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Tried changing things to the below, but still get the same problem.
stWhereClause = "(((tblWelderQu alification.[Test Number]) Like
IIf(Forms!frmTe stSubform!chkTe stNo=True,Forms !frmTestSubform !
TestNo,'*')) And " & _
"((tblWelde rs.[Welder ID]) Like IIf(Forms!frmTe stSubform!
chkWID=True,For ms!frmTestSubfo rm!wID,'*')) And " & _
"((tblWelderQua lification.[WPS No]) Like IIf(Forms!frmTe stSubform!
chkWPS=True,For ms!frmTestSubfo rm!subWPS,'*')) And " & _
"((tblWelderQua lification.Stam ped)=IIf(Forms! frmTestSubform!
chkCertified=Tr ue,True,'*')) And " & _
"((tblWelderQua lification.Proj ect) Like IIf(Forms!frmTe stSubform!
chkProject=True ,Forms!frmTestS ubform!txtProje ct,'*')))"
Also, in the query where I copied this from. If I change "Like" to
"=" on the "stamped" field condition then I get the following error
when I try to view in datasheet view.
"The expression is typed incorrectly, or it is too complex to be
evaluated. For example, a numeric expression may contain too many
complicated elements. Try simplifying the expression by assigning
parts of the expression to variables."
If I change it back to "Like" then it works fine.
I also tried removing the where clause in the OpenReport and adding a
filter, this being the query from which I got the where statement.
This produced the same problem.
Could it be the case that because the "stamped" field is not in the
report I am trying to open is the reason i am getting this error? ru*******@gmail .com wrote:
Tried changing things to the below, but still get the same problem.
stWhereClause = "(((tblWelderQu alification.[Test Number]) Like
IIf(Forms!frmTe stSubform!chkTe stNo=True,Forms !frmTestSubform !
TestNo,'*')) And " & _
"((tblWelde rs.[Welder ID]) Like IIf(Forms!frmTe stSubform!
chkWID=True,For ms!frmTestSubfo rm!wID,'*')) And " & _
"((tblWelderQua lification.[WPS No]) Like IIf(Forms!frmTe stSubform!
chkWPS=True,For ms!frmTestSubfo rm!subWPS,'*')) And " & _
"((tblWelderQua lification.Stam ped)=IIf(Forms! frmTestSubform!
chkCertified=Tr ue,True,'*')) And " & _
"((tblWelderQua lification.Proj ect) Like IIf(Forms!frmTe stSubform!
chkProject=True ,Forms!frmTestS ubform!txtProje ct,'*')))"
Get rid of all the check boxes and use criteria like this...
WHERE (TestNumber = Forms!frmTestSu bform!TestNo
OR Forms!frmTestSu bform!TestNo Is Null)
That returns all rows if the control on the form is empty and only matching rows
when the control on the form has a value in it. (Much simpler)
repeat for other criteria
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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
|
by: Filips Benoit |
last post by:
Dear All,
DoCmd.OpenReport RPT_TEST, A_PREVIEW, QueryAsFilter doesn't work correctly
in A97 but works OK in A2K.
Is this a bug for A97 ?
Filip
|
by: LoopyNZ |
last post by:
Hi there,
I've converted an Access 97 front end to Access 2000, but when I try to
run a VBA DoCmd.OpenReport (e.g. DoCmd.OpenReport
"rpt_programme_listing") line, Access completely crashes ("Microsoft
Access for Windows has encountered a problem and needs to close. We are
sorry for the inconvenience.").
The reports themselves run fine when I double-click on them - it's only
when I try to run them through code (including in the...
|
by: news.onet.pl |
last post by:
Hello!
I have a question concerning to open the reports.
I know that DoCmd.OpenReport is a obsolete form of opening the reports, but
how to implement opening reports in VB using another VB code?
I mean also OpenForm, OpenQuery etc.
Thank you in advance for help
Marcin
|
by: enough2Bdangerous |
last post by:
access runtime error 3011 on docmd.openreport
--------------------------------------------------------------------------------
Access database (file format 2002-2003) generates reports with docmd.openreport but returns 3011 runtime error related to the printer. Switching Windows default printer is a work around but need to find out the cause. Help Desk updated printer driver on server and no runtime error for two months but we are receiving...
| |
by: Simon |
last post by:
Dear reader,
The syntax for Docmd.OpenReport is:
OpenReport(ReportName, View, FilterName, WhereCondition, WindowMode,
OpenArgs)
Example
The following example prints Sales Report while using the existing query
|
by: robtyketto |
last post by:
Greetings,
I originally used a button on a from created via the button wizard (access 2007) to run my report which was based on a query.
Since I wanted to add some validation I removed the button and added my own
code (as below):-
However the open report is just a preview and the user cant exit the preview
screen without directly using access controls.
|
by: scottbouley |
last post by:
Maybe I'm missing something or perhaps there's another way to do this. I'm trying to allow the user to preview and print an invoice as they are exiting from the New Sale form. However, the preview opens but closes after a second. Can anyone give me a clue?
Thanks
Code:
If MsgBox("Do You Want To Create An Invoice?", vbDefaultButton1 + vbYesNo) = vbYes Then
Dim stDocName As String
stDocName =...
|
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...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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...
| |
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |