Results 1 to 4 of 4
  1. #1
    Danny2024 is offline Novice
    Windows 8 Access 2016
    Join Date
    Feb 2018
    Posts
    9

    If and then VBA with multiple subform lines

    Hi

    I have a main form that contains a subform in it which will be used to assign actions

    I am trying to get a status box on the main form to update when all the actions in the subform have been classed as complete in the relevant column

    It works fine when I just have 1 line, however if I have 2 lines (1 as closed and 1 as open) it will change the status when it should not as the 1st line is closed



    I do not want the status to change until all actions have been classed as complete

    VBA Below

    Private Sub Command155_Click()
    If [Tbl_MRB_Actions subform].Form![Action_Status] = "Closed" Then Me.Text152 = "RELEASE PARTS FROM QUALITY CLINIC"
    End Sub

    Any ideas would be great

    Thanks in advance

  2. #2
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    You would probably need to need to count the open statuses, then do the update.
    However this is fraught with difficulties, what if someone adds a status after the existing one is marked as closed? What is someone changes it from closed to open as they made a mistake?

    Rather than try and store this by trying to capture every possible update, simply calculate it.

    On the form header something like this in an unbound control should do what you want;

    Code:
    =IFF(Dcount("Action_Status","YourActionTable" ,"ActionStatus = 'Open' AND YourPKID = " & [YourPKField]) = 0, "RELEASE PARTS FROM QUALITY CLINIC", "Actions Not all Closed")
    Maybe just use the DCount part initially until to get the result you want.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    Danny2024 is offline Novice
    Windows 8 Access 2016
    Join Date
    Feb 2018
    Posts
    9
    Thanks Minty

    I never thought of that

    Will give it a try and update how I get on

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    @Danny2024,

    Can you describe the underlying business supported by your forms in general terms, simple English, and
    show us the tables and relationships (jpg) you currentlty have?

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

Similar Threads

  1. Replies: 1
    Last Post: 05-01-2017, 12:11 PM
  2. Multiple Lines Form
    By DomSza in forum Forms
    Replies: 4
    Last Post: 06-17-2016, 08:46 AM
  3. Replies: 3
    Last Post: 05-01-2014, 09:52 AM
  4. Split one record into multiple lines
    By Sally in forum Access
    Replies: 1
    Last Post: 03-11-2013, 07:03 PM
  5. Creating Multiple Lines per Member
    By SecretGeek in forum Access
    Replies: 2
    Last Post: 08-20-2010, 06:19 AM

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