Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OnOpen event

Status
Not open for further replies.

primerov

Technical User
Aug 16, 2002
160
0
0
BG


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.
 
primerov
What happens if you change the expression to
If Me![TxtMyCategory] = 6 Or Me.[TxtMyCategory] = 12 Then

Tom
 
I don't think the controls have any value in the on open event of the report, but they have in the on format event. In stead of using the controlsource property, why not hide your Me![MyLiters] control, create a new control, txtMyLiters, and in the on format event of the section where the control resides, use:

[tt]select case me("TxtMyCategory").value
case 6, 12
me("txtMyLiters").value = me("MyLiters").value & " kg"
case else
me("txtMyLiters").value = me("MyLiters").value & " liters"
end select[/tt]

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top