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

OnOepn event in report

I need to use the following condition in the OnOpen event of the report

If Me![TxtMyCategory] = 6 Or 12 Then
.........
But i get the error " you entered an expression that has no value"
I can evade the error if i put the expression in the OnFormat event.
But in the OnFormat event i cannot create the control source for the
following line :

Me![MyLiters].ControlSource = "=[liters] & "" kg"""
The above line works only in the OnOpen event,and not in the OnFormat event.
Thus i find myslef in a vicous circle and i cannot do my task.
Is there any possiblity to place the following code in the OnPen event :
If Me![TxtMyCategory] = 6 Or 12 Then
Me![MyLiters].ControlSource = "=[liters] & "" kg"""
Else
Me![MyLiters].ControlSource = "=[liters] & "" liters"""
End If
Just to explain why i need this code.

On each invoice, that may contain 12 products, i need to write kilograms or liters
depending on the category of the product contained in the MyCategory control.
So, for example if the category is 6 ,the products should be in kilograms.
Unfortunately i cannot achieve it. I will be grateful for any help.
Nov 13 '05 #1
1 1074
Actually, your code has a logic error. The syntax you have provided employs
the OR bitwise operator, which isn't what you want, nor does it produce a
value that Access can make a decision on. To improve readability and allow
programmers to quickly see this type of error, programmers place parentheses
around each group of operands in the equation.

You could try the following syntax:

If ((Me!TxtMyCategory.Value = 6) Or (Me!TxtMyCategory.Value = 12)) Then

Using this line with your other code will concatenate the " kg" string at
the end of the string value in your "liters" field when the product category
is either 6 or 12, and the " liters" string would be concatenated for all
other product categories.

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.
"Primerov" <pr******@hotmail.com> wrote in message
news:4a**************************@posting.google.c om...
I need to use the following condition in the OnOpen event of the report

If Me![TxtMyCategory] = 6 Or 12 Then
........
But i get the error " you entered an expression that has no value"
I can evade the error if i put the expression in the OnFormat event.
But in the OnFormat event i cannot create the control source for the
following line :

Me![MyLiters].ControlSource = "=[liters] & "" kg"""
The above line works only in the OnOpen event,and not in the OnFormat event. Thus i find myslef in a vicous circle and i cannot do my task.
Is there any possiblity to place the following code in the OnPen event :
If Me![TxtMyCategory] = 6 Or 12 Then
Me![MyLiters].ControlSource = "=[liters] & "" kg"""
Else
Me![MyLiters].ControlSource = "=[liters] & "" liters"""
End If
Just to explain why i need this code.

On each invoice, that may contain 12 products, i need to write kilograms or liters depending on the category of the product contained in the MyCategory control. So, for example if the category is 6 ,the products should be in kilograms.
Unfortunately i cannot achieve it. I will be grateful for any help.

Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: CSDunn | last post by:
Hello, In an Access 2003 Project that uses a SQL Server 2000 database as its data source, I am attempting to set the RecordSource property of a sub report called 'RptTeacherHistory2' that appears...
3
by: Melissa | last post by:
What specifically causes the Format event of a report's section to fire? Thanks! Melissa
2
by: CSDunn | last post by:
Hello, I have an Access 2003 report that opens in print preview and then maximizes upon clicking a button from a form. The OnClick event of the button fires a macro to open the report. How can...
3
by: deejayquai | last post by:
Hi I've created a crosstab query and displayed it as a sub-report in my main report. This is fine until the data changes and the column names become incorrect. I know I have to create a...
1
by: gus kernot | last post by:
I have copied code from the MS Knowledge Base that produces the above report. I understand the code and am pretty comfortable working with recordsets. I used the same report structure...
6
by: Bob Alston | last post by:
I am looking for Access reporting add-in that would be easy to use by end users. My key focus is on selection criteria. I am very happy with the Access report writer capabilities. As far as...
4
by: Andrew Meador - ASCPA, MCSE, MCP+I, Network+, A+ | last post by:
I have created a report. This report needs to display records between two dates entered by the user. I put two text boxes on the report so I can enter the start and end date - I set them to use an...
3
by: franc sutherland | last post by:
Hello, I have a report which I filter using the me.filter command in the OnOpen event. Me.Filter = "OrderID=" & Forms!variable_form_name! Me.FilterOn = True I want to be able to open that...
11
by: Gord | last post by:
When I open a certain report, it runs some code that generates the records that will be displayed in that report. This works fine. When I go to print preview the report it appears that the code...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.