OnOepn event in report

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Primerov

    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.
  • '69 Camaro

    #2
    Re: OnOepn event in report

    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!TxtMyCateg ory.Value = 6) Or (Me!TxtMyCatego ry.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" <primerov@hotma il.com> wrote in message
    news:4a25e7d1.0 408080218.345ab fd7@posting.goo gle.com...[color=blue]
    > 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[/color]
    event.[color=blue]
    > 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[/color]
    or liters[color=blue]
    > depending on the category of the product contained in the MyCategory[/color]
    control.[color=blue]
    > 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.[/color]


    Comment

    Working...