By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,635 Members | 913 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,635 IT Pros & Developers. It's quick & easy.

OnOepn event in report

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.