Results 1 to 12 of 12
  1. #1
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2002
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383

    Show Label If One Field Value Less Than Another Field Value

    If Me.UnitsInStock.Value < Me.SetReOrderLevel Then 'both are numeric fields. NOT WORKING ?
    Me.Label69.Visible = True ' Label69 default is not visible
    End If


    Don't know why this does not work,Right now UnitsinStock has 19 in stock and SetReOrderLevel has been set to 20

    Sorry for the Forest Gump Post!



    Having a moment.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Where is the code? You probably want an Else clause to set it back to invisible as appropriate.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2002
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    It is run on the oncurrent event. Since I already have the default set to Invisible, is this still necessary?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Sure; what if you navigate to a record that shouldn't display the label after being on one that should?

    If it's not working, have you set a breakpoint to check the values? Is the code running at all (is any code running)?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2002
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    The form is a continuous form, but if the value is not there, i.e. less than, then the label should not be visible anyway. Oh, I see your point, I do need a else statement, Hmmm!
    The code does no give any errors, it just does not work. I compile and no runs, no hits, no errors.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Can you post the db here? Also, in a continuous form this (using code) will not really achieve the desired look. You might use a textbox instead of a label and use Conditional Formatting.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2002
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383

    Show Label If One Field Value Less Than Another Field Value

    Ok, here is the necessary form,query and tables, zipped.
    Attached Files Attached Files

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Your fields are text, not numeric. Try

    If CLng(Me.UnitsInStock.Value) < CLng(Me.SetReOrderLevel) Then ' If Inventory Level is Low, Reorder Message.Both are numbers
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2002
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    That works for the first record, but if you go to the next record, you get an error message; Run Time Error 94, Invalid use of Null

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    That's because there are Null values. Use the Nz() function if that's a possibility in the actual db.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2002
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Ok, I tried UNsuccesfully with this code;

    If CLng(Nz([UnitsInStock], 0).Value) < CLng(Nz([SetReOrderLevel], 0)) Then ' If Inventory Level is Low, Reorder Message.
    Me.Label69.Visible = True
    Else
    Me.Label69.Visible = False
    End If

    ____________________________________
    I also set the field values to ; =Nz([UnitsInStock],0)

    ______________________________
    Error Message is Run Tim error 424 Object Required ????

  12. #12
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    More like:

    CLng(Nz(Me.UnitsInStock.Value, 0))
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. How to show field content in a Label?
    By robertdbuckley in forum Access
    Replies: 3
    Last Post: 05-24-2012, 04:02 AM
  2. Query Help - Show field if another field is null
    By lukekonrad in forum Access
    Replies: 1
    Last Post: 03-05-2012, 04:02 PM
  3. Replies: 1
    Last Post: 12-28-2011, 11:37 AM
  4. Show label on report only if data in field
    By senna in forum Reports
    Replies: 1
    Last Post: 01-31-2011, 06:11 AM
  5. Vertical centering in a Label field?
    By newtoAccess in forum Access
    Replies: 1
    Last Post: 11-07-2010, 11:01 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums