Page 1 of 3 123 LastLast
Results 1 to 15 of 35
  1. #1
    FoxMan250 is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    May 2014
    Posts
    18

    If Then Expressions?

    Hey guys,

    I'm new to this forum and also extremely new to Access. We currently use Access to have our employees look up Lockout Tagout safety procedures at our plant. I was put in charge of updating it, and since I didn't design it, I'm a bit overwhelmed and need some help.

    I've worked with Excel and C# a bit so I'm ok with some understanding of programming, but not much so I may need things dumbed down.

    Here's what I'm trying to do (bear with me since this is tough to explain):

    - We have a table that holds all the pieces of equipment with their name and number
    - We have a second table of equipment numbers and procedures that is linked to the numbers in the first table. When an employee types in the equipment number in the user interface (linked to the first table), the second table populates the below section of the interface by showing the procedures to use.
    - Then we have a third and fourth table labelled "Upstream" and "Downstream". These tables have 2 columns for numbers. The first column is for the main equipment number and the second column is for either the upstream or downstream equipment number. These populate the upstream and downstream section of the interface.

    Here's what the interface looks like when done:
    Click image for larger version. 

Name:	AB.jpg 
Views:	18 
Size:	144.6 KB 
ID:	16361

    What I want to do is have a phrase appear in the "Unusual Precautions" section ONLY when certain equipment numbers are in the top section and not have the phrase appear when that same piece of equipment appears in the upstream and downstream sections.

    Sorry for the lengthy explanation but any notes on how to do an "IF/Then" expression by cell in access or something along those lines would really help.



    Thanks in advance

  2. #2
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Edit to suit your needs for Criteria.
    If Me.EquipmentNumber = 1 Then
    Me.lblSomeLabel.Caption = "Say Something"
    Else
    Me.lblSomeLabel.Caption = ""
    End If
    HTH

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,913
    I see field caption "Unusual Cautions" but not "Unusual Precautions". Where exactly to you want the message to appear - in each record of each subform or only in the header of main form?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    FoxMan250 is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    May 2014
    Posts
    18
    Quote Originally Posted by June7 View Post
    I see field caption "Unusual Cautions" but not "Unusual Precautions". Where exactly to you want the message to appear - in each record of each subform or only in the header of main form?
    Sorry, i meant "Unusual Cautions". I'd like the message to only appear in that cell for the equipment when it is the main equipment (first row), and have it not appear if that same piece of equipment were to show up as an upstream or downstream for a different main piece of equipment.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,913
    This message would show ONLY in the first record of first subform?
    For the posted example, message should show for 0-02-11 record?
    But if 0-02-11 was listed in either Upstream or Downstream, do not show message?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    FoxMan250 is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    May 2014
    Posts
    18
    Quote Originally Posted by June7 View Post
    This message would show ONLY in the first record of first subform?
    For the posted example, message should show for 0-02-11 record?
    But if 0-02-11 was listed in either Upstream or Downstream, do not show message?
    Exactly! That's what I'm trying to accomplish.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,913
    Sounds veeeeerrrrry difficult. I think too complicated for a textbox expression and a custom function will be needed.

    1. First complication is making the message show in only the first record of the top form.

    2. Then must search records of the other forms to determine if the value is in any record.
    Maybe DLookup or DCount on the tables with appropriate filter criteria.
    Or maybe opening DAO recordset objects of the other two form RecordSources and use FindFirst method.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    FoxMan250 is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    May 2014
    Posts
    18
    Quote Originally Posted by June7 View Post
    Sounds veeeeerrrrry difficult. I think too complicated for a textbox expression and a custom function will be needed.

    1. First complication is making the message show in only the first record of the top form.

    2. Then must search records of the other forms to determine if the value is in any record.
    Maybe DLookup or DCount on the tables with appropriate filter criteria.
    Or maybe opening DAO recordset objects of the other two form RecordSources and use FindFirst method.
    I was afraid this would get difficult. Is there a way to set the print field perhaps? Maybe I could create a print button that would exclude the upstream and downstream sections from the print field?

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,913
    What is the 'print' field?

    Excluding records is the same issue. Need to do determine same parameters as for displaying message.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    FoxMan250 is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    May 2014
    Posts
    18
    Quote Originally Posted by June7 View Post
    What is the 'print' field?

    Excluding records is the same issue. Need to do determine same parameters as for displaying message.
    I was thinking similar to excel where you can set certain groups of cells to be printed while excluding other surrounding cells. Well shoot, I'm at a loss for ideas here.

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,913
    Anything can be done with enough code. This is just a bit unusual requirement and will require somewhat advanced programming skill.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  12. #12
    FoxMan250 is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    May 2014
    Posts
    18
    Advance being what would hold me back with my lack of skills with this program... :/

    What if I added another cell to each piece of equipment that the message could be written in, but then only make that cell show up in the main section and not the others. That way I'm only restricting what cells are in view rather than text?

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,913
    Including or excluding a field in form is simple. You would then manually edit the field for the first record depending on your direct analysis of the displayed records? That does seem to be an option.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  14. #14
    FoxMan250 is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    May 2014
    Posts
    18
    Yeah that might be the best way to go here, or try to at least.

    I'm trying to add in a special circumstances statement basically.

    I wanted to have the description:

    FOR EXTERNAL WORK
    (No Exposure to Inside of Housing)
    Only this piece of equipment needs locked out.
    No Upstream or Downstream locking required.

    So If I added another cell next to "Unusual Cautions" for all pieces of equipment, but then wanted to hide or exclude that cell for just the Upstream and Downstream areas, how would I go about doing that?

  15. #15
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,913
    Rethink your terminology. It's not a 'cell', its a control (textbox, combobox, label, etc).

    Aren't these three subforms? If you don't want this field to display on form then don't include it in form design.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Page 1 of 3 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Expressions in Form
    By Deb4566 in forum Access
    Replies: 7
    Last Post: 03-08-2013, 12:18 PM
  2. Expressions in DLookUp
    By Jim Pap in forum Programming
    Replies: 1
    Last Post: 12-22-2012, 12:02 PM
  3. Expressions between two tables
    By ExcelleradRob in forum Access
    Replies: 2
    Last Post: 09-28-2012, 12:45 PM
  4. Repeat Expressions
    By welshmpf in forum Access
    Replies: 8
    Last Post: 09-06-2011, 09:41 AM
  5. Query Expressions
    By Andrea in forum Queries
    Replies: 6
    Last Post: 03-03-2011, 03:57 PM

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