Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Cornwall, England
    Posts
    393
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Show Label when value below 0 (access97)

    Hi,
    I have a form that has a text box displaying the sum of two other textboxes. If the value of this textbox goes below 0 (zero) (ie. we have over paid the project) then i want to show a label to this effect. so far i have
    a sub procedure that checks the value of txtTotal like this:
    Sub Warning()
    Stop
    If Me.txtTotal < 0 Then
    lblWarning.Visible = True
    Else
    lblWarning.Visible = False
    End If
    End Sub

    the stop line is there for me to step through the code when processing reaches that point..

    the problem is , no matter where i put the call to run this procedure the code never reaches Sub Warning. <img src=/S/brickwall.gif border=0 alt=brickwall width=25 height=15>
    i have tried the form_afterupdate and _current and i have tried the txtTotal_afterupdate and _change.

    The two textboxes that are used in the calculation get their values from a sub form - is this a problem?

    please, where am i going wrong ?

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Show Label when value below 0 (access97)

    Hi,
    I'd have said that the easiest way to achieve this would be to use a text box rather than a label. You could then use something like:
    =IIf([text0]<0,"Project overpaid!","")
    as the control source for the new text box, which you can format as Flat, transparent background, disabled and locked. It will then only be visible to the user when your other textbox value goes below 0.
    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Cornwall, England
    Posts
    393
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Show Label when value below 0 (access97)

    brilliant idea, i wish i had lateral thinking like that. I guess it comes from programming in an environment where i'm not used to all the shortcuts of Access

    The only problem i have now is an error when the form loads. Grrrrrrrrrrrr

    i have substitued Text0 for my textbox name but got #Name?
    I then tried to explicitly reference the textbox with the form name - no change
    removed [frmName] from control source and i now get #Error !!!!!!!!

  4. #4
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Show Label when value below 0 (access97)

    What error did you get when the form loads? (Text0 should be replaced with your textbox name)
    Regards,
    Rory

    Microsoft MVP - Excel

  5. #5
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Cornwall, England
    Posts
    393
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Show Label when value below 0 (access97)

    Rory,
    The error only displayed what i detailed previously , in the text box, the rest of the form loaded OK. Text0 was replaced !
    I have, just now, got this to work by using the query builder wizard on the control source line. The resulting control source is exactly what was in the cell before. ie =IIF([txtTotal]>0 ,"Project overspend","")
    AAAAARRRRRGGGGGHHHH !
    thanks for your assistance.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •