Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    gaker10 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2014
    Posts
    262

    Change combobox field fill color if list is populated


    I have combobox with a specific rowsource. Can I change the fill color of the combobox when the list for the combobox (based on the rowsource) changes?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    What causes the list to change?
    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.

  3. #3
    gaker10 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2014
    Posts
    262
    Entry/selection into another combobox.

  4. #4
    nick404's Avatar
    nick404 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2015
    Location
    Wisconsin
    Posts
    352
    You are using one combo box to change the row source for another combo box based on selection?
    ComboBox1 selection results in ComboBox2 changing row sources?

  5. #5
    gaker10 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2014
    Posts
    262
    Whatever is typed into combobox1, a lookup is performed on combobox2 for the combobox1 value in tableX, and a field value is returned and populates the list for combobox2.

  6. #6
    nick404's Avatar
    nick404 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2015
    Location
    Wisconsin
    Posts
    352
    Okay, to change the back color after the value is selected from combo1 do this:

    Properties -> Events tab -> After Update event -> Click the ellipses (...)

    Then put this code there using the correct names for you combo box(s).
    Code:
    Private Sub YourCombo1_AfterUpdate()
    Me.Combo2.BackColor = vbYellow  ' or whatever color you want
    End Sub
    I just put vbYellow in there for filler. There is vbRed, vbCyan, vbYellow, vbWhite, vbBlue, vbBlack, vbMagenta, vbGreen.

    Or if you want to get real specific check out http://cloford.com/resources/colours/500col.htm for over 500 color codes. You can test out the color by pressing the color's name in the third column of the table on the site.
    If you want to use one you see on there, the last column is titled 'Access', copy and past the number sequence after .BackColor = [paste #s] and you are good to go. Ignore the 'Hex', R, G, and B, columns.
    Last edited by nick404; 08-04-2015 at 08:57 AM. Reason: edited, forgot code tags

  7. #7
    gaker10 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2014
    Posts
    262
    It works The only problem is:

    1. Updating combobox1 MAY NOT yield an updated list to combobox2. For example, I type a value into combobox1, the lookup is performed, but no value exists to populate combobox2. I would only like to highlight the combobox2 ONLY if a value in the list is populated.
    2. If a value is found to populate combobox2, and this value is selected from the drop down, remove the yellow fill color.

    The purpose of this is that whomever is using the form remembers to pick the value from the combobox2 if a value is there to select.

    Also, there is code already in function "Private Sub YourCombo1_AfterUpdate()" : YourCombo1 here is cboComponent, and combobox2 is txtAlternateA (its a combobox with a "txt" label, sorry D: )

    Code:
    Private Sub cboComponent_AfterUpdate()
    Dim strPN As String
    
    
    'Replace drawing number with Primary part if the entry is a drawing
    strPN = Nz(DLookup("Primary", "DRAWINGS", "Drawing='" & Me.cboComponent & "'"), "")
    
    
    'If the string is not empty
    If strPN <> "" Then
    'this is a DRAWING, set component value and corresponding information
    Me.txtComponent = Nz(DLookup("Primary", "DRAWINGS", "Drawing='" & Me.cboComponent & "'"), "")
    Me.txtDescription = DLookup("Description", "PDatabase", "[PartNumber] = '" & Me.txtComponent & "'")
    Me.txtUOM = DLookup("PurchaseUOM", "PDatabase", "[PartNumber] = '" & Me.txtComponent & "'")
    Me.txtCageCode = DLookup("CageCodeA", "Drawings", "[Drawing] = '" & Me.cboComponent & "'")
    Me.txtCageCodeA = DLookup("CageCodeB", "Drawings", "[Drawing] = '" & Me.cboComponent & "'")
    Me.txtCageCodeB = DLookup("CageCodeC", "Drawings", "[Drawing] = '" & Me.cboComponent & "'")
    Me.txtCageCodeC = DLookup("CageCodeD", "Drawings", "[Drawing] = '" & Me.cboComponent & "'")
    Me.Revision = DLookup("Revision", "Drawings", "[Drawing] = '" & Me.cboComponent & "'")
    
    
    'Load AlternateA into the drop down
    On Error Resume Next
       txtAlternateA.RowSource = "SELECT DRAWINGS.AlternateA " & _
                "FROM DRAWINGS " & _
                "WHERE DRAWINGS.Primary = '" & Me.txtComponent & "' " & _
                "ORDER BY DRAWINGS.AlternateA; "
                    
    'Load AlternateB into the drop down
    On Error Resume Next
       txtAlternateB.RowSource = "Select DRAWINGS.AlternateB " & _
                "FROM DRAWINGS " & _
                "WHERE DRAWINGS.Primary = '" & Me.txtComponent & "' " & _
                "ORDER BY DRAWINGS.AlternateB;"
                
    'Load AlternateC into the drop down
    On Error Resume Next
       txtAlternateC.RowSource = "Select DRAWINGS.AlternateC " & _
                "FROM DRAWINGS " & _
                "WHERE DRAWINGS.Primary = '" & Me.txtComponent & "' " & _
                "ORDER BY DRAWINGS.AlternateC;"
    
    
    'If this is not a drawing, its an assembly/kit or regular part with possible alternates
    ElseIf strPN = "" Then
    
    
    'Compare entry to assembly and kit numbers in the table
    strPN = Nz(DLookup("AssemblyKitNumber", "ASSEMBLIESKITS", "[AssemblyKitNumber]='" & Me.cboComponent & "'"), "")
    
    
        'If a match is found
        If strPN <> "" Then
                'this is an assembly or kit
                Me.txtComponent = strPN
                Me.txtDescription = DLookup("Description", "ASSEMBLIESKITS", "[AssemblyKitNumber] ='" & Me.txtComponent & "'")
                Me.txtUOM = DLookup("UOM", "ASSEMBLIESKITS", "[AssemblyKitNumber] ='" & Me.txtComponent & "'")
            
            'Load all parts for possible alternates in drop down
               txtAlternateA.RowSource = "SELECT PDatabase.PartNumber " & _
                        "FROM PDatabase " & _
                        "ORDER BY PDatabase.PartNumber; "
                        
                txtAlternateB.RowSource = "SELECT PDatabase.PartNumber " & _
                        "FROM PDatabase " & _
                        "ORDER BY PDatabase.PartNumber; "
                        
                txtAlternateC.RowSource = "SELECT PDatabase.PartNumber " & _
                        "FROM PDatabase " & _
                        "ORDER BY PDatabase.PartNumber; "
        
        Else
        'This is a part number
        Me.txtComponent = Me.cboComponent
            Me.txtDescription = DLookup("Description", "PDatabase", "[PartNumber] = '" & Me.txtComponent & "'")
            Me.txtUOM = DLookup("PurchaseUOM", "PDatabase", "[PartNumber] = '" & Me.txtComponent & "'")
                  
                                
        
        strPN = Nz(DLookup("AlternateA", "ALTERNATES", "[PartNumber]='" & Me.txtComponent & "'"), "")
        
        If strPN <> "" Then
           txtAlternateA.RowSource = "SELECT ALTERNATES.AlternateA " & _
                    "FROM ALTERNATES " & _
                    "WHERE ALTERNATES.PartNumber = '" & Me.txtComponent & "' " & _
                    "ORDER BY ALTERNATES.AlternateA; "
        Else
           txtAlternateA.RowSource = "SELECT PDatabase.PartNumber " & _
                    "FROM PDatabase " & _
                    "ORDER BY PDatabase.PartNumber; "
        End If
        
        strPN = Nz(DLookup("AlternateB", "ALTERNATES", "[PartNumber]='" & Me.txtComponent & "'"), "")
                    
        If strPN <> "" Then
           txtAlternateA.RowSource = "SELECT ALTERNATES.AlternateB " & _
                    "FROM ALTERNATES " & _
                    "WHERE ALTERNATES.PartNumber = '" & Me.txtComponent & "' " & _
                    "ORDER BY ALTERNATES.AlternateB; "
        Else
            txtAlternateB.RowSource = "SELECT PDatabase.PartNumber " & _
                    "FROM PDatabase " & _
                    "ORDER BY PDatabase.PartNumber; "
            End If
            
            strPN = Nz(DLookup("AlternateC", "ALTERNATES", "[PartNumber]='" & Me.txtComponent & "'"), "")
                    
        If strPN <> "" Then
           txtAlternateC.RowSource = "SELECT ALTERNATES.AlternateC " & _
                    "FROM ALTERNATES " & _
                    "WHERE ALTERNATES.PartNumber = '" & Me.txtComponent & "' " & _
                    "ORDER BY ALTERNATES.AlternateC; "
        Else
            txtAlternateC.RowSource = "SELECT PDatabase.PartNumber " & _
                    "FROM PDatabase " & _
                    "ORDER BY PDatabase.PartNumber; "
            End If
        
        End If
    End If
    
    
    
    
    End Sub
    Sorry I forgot to mention this code.

  8. #8
    nick404's Avatar
    nick404 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2015
    Location
    Wisconsin
    Posts
    352
    I looked whereever I saw you assigning a row source to the txtAlternate and inserted the orange line of code assigning a new back color.
    Code:
    Private Sub cboComponent_AfterUpdate()
    Dim strPN As String
    
    
    'Replace drawing number with Primary part if the entry is a drawing
    strPN = Nz(DLookup("Primary", "DRAWINGS", "Drawing='" & Me.cboComponent & "'"), "")
    
    
    'If the string is not empty
    If strPN <> "" Then
    'this is a DRAWING, set component value and corresponding information
    Me.txtComponent = Nz(DLookup("Primary", "DRAWINGS", "Drawing='" & Me.cboComponent & "'"), "")
    Me.txtDescription = DLookup("Description", "PDatabase", "[PartNumber] = '" & Me.txtComponent & "'")
    Me.txtUOM = DLookup("PurchaseUOM", "PDatabase", "[PartNumber] = '" & Me.txtComponent & "'")
    Me.txtCageCode = DLookup("CageCodeA", "Drawings", "[Drawing] = '" & Me.cboComponent & "'")
    Me.txtCageCodeA = DLookup("CageCodeB", "Drawings", "[Drawing] = '" & Me.cboComponent & "'")
    Me.txtCageCodeB = DLookup("CageCodeC", "Drawings", "[Drawing] = '" & Me.cboComponent & "'")
    Me.txtCageCodeC = DLookup("CageCodeD", "Drawings", "[Drawing] = '" & Me.cboComponent & "'")
    Me.Revision = DLookup("Revision", "Drawings", "[Drawing] = '" & Me.cboComponent & "'")
    
    
    'Load AlternateA into the drop down
    On Error Resume Next
       txtAlternateA.RowSource = "SELECT DRAWINGS.AlternateA " & _
                "FROM DRAWINGS " & _
                "WHERE DRAWINGS.Primary = '" & Me.txtComponent & "' " & _
                "ORDER BY DRAWINGS.AlternateA; "
                Me.txtAlternateA.BackColor = vbYellow
                    
    'Load AlternateB into the drop down
    On Error Resume Next
       txtAlternateB.RowSource = "Select DRAWINGS.AlternateB " & _
                "FROM DRAWINGS " & _
                "WHERE DRAWINGS.Primary = '" & Me.txtComponent & "' " & _
                "ORDER BY DRAWINGS.AlternateB;"
                Me.txtAlternateB.BackColor = vbYellow
                
    'Load AlternateC into the drop down
    On Error Resume Next
       txtAlternateC.RowSource = "Select DRAWINGS.AlternateC " & _
                "FROM DRAWINGS " & _
                "WHERE DRAWINGS.Primary = '" & Me.txtComponent & "' " & _
                "ORDER BY DRAWINGS.AlternateC;"
                Me.txtAlternateC.BackColor = vbYellow
    
    'If this is not a drawing, its an assembly/kit or regular part with possible alternates
    ElseIf strPN = "" Then
    
    'Compare entry to assembly and kit numbers in the table
    strPN = Nz(DLookup("AssemblyKitNumber", "ASSEMBLIESKITS", "[AssemblyKitNumber]='" & Me.cboComponent & "'"), "")
    
        'If a match is found
        If strPN <> "" Then
                'this is an assembly or kit
                Me.txtComponent = strPN
                Me.txtDescription = DLookup("Description", "ASSEMBLIESKITS", "[AssemblyKitNumber] ='" & Me.txtComponent & "'")
                Me.txtUOM = DLookup("UOM", "ASSEMBLIESKITS", "[AssemblyKitNumber] ='" & Me.txtComponent & "'")
            
            'Load all parts for possible alternates in drop down
               txtAlternateA.RowSource = "SELECT PDatabase.PartNumber " & _
                        "FROM PDatabase " & _
                        "ORDER BY PDatabase.PartNumber; "
                        Me.txtAlternateA.BackColor = vbYellow
    
                txtAlternateB.RowSource = "SELECT PDatabase.PartNumber " & _
                        "FROM PDatabase " & _
                        "ORDER BY PDatabase.PartNumber; "
                        Me.txtAlternateB.BackColor = vbYellow
    
                txtAlternateC.RowSource = "SELECT PDatabase.PartNumber " & _
                        "FROM PDatabase " & _
                        "ORDER BY PDatabase.PartNumber; "
                        Me.txtAlternateC.BackColor = vbYellow
    
        Else
        'This is a part number
        Me.txtComponent = Me.cboComponent
            Me.txtDescription = DLookup("Description", "PDatabase", "[PartNumber] = '" & Me.txtComponent & "'")
            Me.txtUOM = DLookup("PurchaseUOM", "PDatabase", "[PartNumber] = '" & Me.txtComponent & "'")                         
        
        strPN = Nz(DLookup("AlternateA", "ALTERNATES", "[PartNumber]='" & Me.txtComponent & "'"), "")
        
        If strPN <> "" Then
           txtAlternateA.RowSource = "SELECT ALTERNATES.AlternateA " & _
                    "FROM ALTERNATES " & _
                    "WHERE ALTERNATES.PartNumber = '" & Me.txtComponent & "' " & _
                    "ORDER BY ALTERNATES.AlternateA; "
                    Me.txtAlternateA.BackColor = vbYellow
        Else
           txtAlternateA.RowSource = "SELECT PDatabase.PartNumber " & _
                    "FROM PDatabase " & _
                    "ORDER BY PDatabase.PartNumber; "
                    Me.txtAlternateA.BackColor = vbYellow
    
        End If
        
        strPN = Nz(DLookup("AlternateB", "ALTERNATES", "[PartNumber]='" & Me.txtComponent & "'"), "")
                    
        If strPN <> "" Then
           txtAlternateA.RowSource = "SELECT ALTERNATES.AlternateB " & _
                    "FROM ALTERNATES " & _
                    "WHERE ALTERNATES.PartNumber = '" & Me.txtComponent & "' " & _
                    "ORDER BY ALTERNATES.AlternateB; "
                    Me.txtAlternateA.BackColor = vbYellow
        Else
            txtAlternateB.RowSource = "SELECT PDatabase.PartNumber " & _
                    "FROM PDatabase " & _
                    "ORDER BY PDatabase.PartNumber; "
                    Me.txtAlternateB.BackColor = vbYellow
            End If
            
            strPN = Nz(DLookup("AlternateC", "ALTERNATES", "[PartNumber]='" & Me.txtComponent & "'"), "")
                    
        If strPN <> "" Then
           txtAlternateC.RowSource = "SELECT ALTERNATES.AlternateC " & _
                    "FROM ALTERNATES " & _
                    "WHERE ALTERNATES.PartNumber = '" & Me.txtComponent & "' " & _
    "ORDER BY ALTERNATES.AlternateC; "
                    Me.txtAlternateC.BackColor = vbYellow
        Else
            txtAlternateC.RowSource = "SELECT PDatabase.PartNumber " & _
                    "FROM PDatabase " & _
                    "ORDER BY PDatabase.PartNumber; "
                    Me.txtAlternateC.BackColor = vbYellow
            End If
        
        End If
    End If
    
    End Sub
    If you want the back color to return to normal after user selects something from the combo. In the AfterUpdate of your dependent combo box set the backcolor to vbWhite. Something similar to:
    Code:
    Private Sub ComboBoxDep_AfterUpdate()
    If Not IsNull(me.cboDep) Then
    Me.cbDep2.BackColor = vbWhite
    End If
    End Sub
    where cboDep = any and all dependent combo boxes.
    Last edited by nick404; 08-04-2015 at 11:32 AM. Reason: code tags, info

  9. #9
    gaker10 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2014
    Posts
    262
    All works with one exception as per Post # 7 Item 1: 1. Updating combobox1 MAY NOT yield an updated list to combobox2. For example, I type a value into combobox1, the lookup is performed, but no value exists to populate combobox2. I would only like to highlight the combobox2 ONLY if a value in the list is populated.


    I typed a value in combobox1, the lookup is performed, and a value does not exist for one of the lookups, but the back color still turns yellow.

    Example:

    I type a value in combobox1:

    Click image for larger version. 

Name:	exampleinput.png 
Views:	21 
Size:	16.8 KB 
ID:	21526

    This value exists in the respective table, so it finds it and does the lookup:

    Click image for larger version. 

Name:	populating.png 
Views:	21 
Size:	17.2 KB 
ID:	21527

    All fields are highlighted, so I populate the drop down fields which are the result of a lookup (on the rowsource per the code above):

    Click image for larger version. 

Name:	emptyalt.png 
Views:	20 
Size:	22.7 KB 
ID:	21528

    AlternateA field performed correctly in that it had a value in its rowsource, and therefore highlighted. When I selected a value, it returned to no fill color upon selection.

    AlternateB field above does not have a value in it's rowsource. This field should have no fill color because it has no values in it's rowsource.

    The same is the case for the AlternateC field.

  10. #10
    nick404's Avatar
    nick404 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2015
    Location
    Wisconsin
    Posts
    352
    Okay I think the area that may be giving you the problem is here
    Code:
        'If a match is found
        If strPN <> "" Then
                'this is an assembly or kit
                Me.txtComponent = strPN
                Me.txtDescription = DLookup("Description", "ASSEMBLIESKITS", "[AssemblyKitNumber] ='" & Me.txtComponent & "'")
                Me.txtUOM = DLookup("UOM", "ASSEMBLIESKITS", "[AssemblyKitNumber] ='" & Me.txtComponent & "'")
            
            'Load all parts for possible alternates in drop down
               txtAlternateA.RowSource = "SELECT PDatabase.PartNumber " & _
                        "FROM PDatabase " & _
                        "ORDER BY PDatabase.PartNumber; "
                        Me.txtAlternateA.BackColor = vbYellow
    
                txtAlternateB.RowSource = "SELECT PDatabase.PartNumber " & _
                        "FROM PDatabase " & _
                        "ORDER BY PDatabase.PartNumber; "
                        Me.txtAlternateB.BackColor = vbYellow
    
                txtAlternateC.RowSource = "SELECT PDatabase.PartNumber " & _
                        "FROM PDatabase " & _
                        "ORDER BY PDatabase.PartNumber; "
                        Me.txtAlternateC.BackColor = vbYellow
    
    You load all alternatives at once, but in the cases where there is none, the back color still changes. So we will want something to test whether the combo box has a non-zero collection, and if it doesn't- then change the color to white.

    So perhaps something like this...
    Code:
        'If a match is found
        If strPN <> "" Then
                'this is an assembly or kit
                Me.txtComponent = strPN
                Me.txtDescription = DLookup("Description", "ASSEMBLIESKITS", "[AssemblyKitNumber] ='" & Me.txtComponent & "'")
                Me.txtUOM = DLookup("UOM", "ASSEMBLIESKITS", "[AssemblyKitNumber] ='" & Me.txtComponent & "'")
            
           'Load all parts for possible alternates in drop down
               txtAlternateA.RowSource = "SELECT PDatabase.PartNumber " & _
                        "FROM PDatabase " & _
                        "ORDER BY PDatabase.PartNumber; "
                             If txtAlternateA.Items.Count = 0 Then txtAlternateA.BackColor = vbWhite
                             Else Me.txtAlternateA.BackColor = vbYellow
                             End If
    
                txtAlternateB.RowSource = "SELECT PDatabase.PartNumber " & _
                        "FROM PDatabase " & _
                        "ORDER BY PDatabase.PartNumber; "
                             If txtAlternateB.Items.Count = 0 Then txtAlternateB.BackColor = vbWhite
                             Else Me.txtAlternateB.BackColor = vbYellow
                             End If
    
                txtAlternateC.RowSource = "SELECT PDatabase.PartNumber " & _
                        "FROM PDatabase " & _
                        "ORDER BY PDatabase.PartNumber; "
                             If txtAlternateC.Items.Count = 0 Then txtAlternateC.BackColor = vbWhite
                             Else Me.txtAlternateC.BackColor = vbYellow
                             End If
    


    Added blue lines, see if that works?
    Last edited by nick404; 08-05-2015 at 07:29 AM. Reason: syntax

  11. #11
    gaker10 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2014
    Posts
    262
    Code:
    'If a match is found
        If strPN <> "" Then
                'this is an assembly or kit
                Me.txtComponent = strPN
                Me.txtDescription = DLookup("Description", "ASSEMBLIESKITS", "[AssemblyKitNumber] ='" & Me.txtComponent & "'")
                Me.txtUOM = DLookup("UOM", "ASSEMBLIESKITS", "[AssemblyKitNumber] ='" & Me.txtComponent & "'")
            
           'Load all parts for possible alternates in drop down
               txtAlternateA.RowSource = "SELECT PDatabase.PartNumber " & _
                        "FROM PDatabase " & _
                        "ORDER BY PDatabase.PartNumber; "
                             If txtAlternateA.Items.Count = 0 Then txtAlternateA.BackColor = vbWhite
                             Else Me.txtAlternateA.BackColor = vbYellow
                             End If
    
                txtAlternateB.RowSource = "SELECT PDatabase.PartNumber " & _
                        "FROM PDatabase " & _
                        "ORDER BY PDatabase.PartNumber; "
                             If txtAlternateB.Items.Count = 0 Then txtAlternateB.BackColor = vbWhite
                             Else Me.txtAlternateB.BackColor = vbYellow
                             End If
    
                txtAlternateC.RowSource = "SELECT PDatabase.PartNumber " & _
                        "FROM PDatabase " & _
                        "ORDER BY PDatabase.PartNumber; "
                             If txtAlternateC.Items.Count = 0 Then txtAlternateC.BackColor = vbWhite
                             Else Me.txtAlternateC.BackColor = vbYellow
                             End If
    The red portions cause a compile error: Method or data member not found.

  12. #12
    nick404's Avatar
    nick404 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2015
    Location
    Wisconsin
    Posts
    352
    Hmm try .ListCount instad perhaps;
    Code:
    If Me.txtAlternateA.ListCount = 0 Then txtAlternateC.BackColor = vbWhite

  13. #13
    gaker10 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2014
    Posts
    262
    Field still turns yellow when list is empty.

  14. #14
    nick404's Avatar
    nick404 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2015
    Location
    Wisconsin
    Posts
    352
    Try putting that if statement at each row source change. Since I don't really know what you type in causes which lookup to run, see if that works.

  15. #15
    gaker10 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2014
    Posts
    262
    I did:

    Code:
    'If a match is found
        If strPN <> "" Then
                'this is an assembly or kit
                Me.txtComponent = strPN
                Me.txtDescription = DLookup("Description", "ASSEMBLIESKITS", "[AssemblyKitNumber] ='" & Me.txtComponent & "'")
                Me.txtUOM = DLookup("UOM", "ASSEMBLIESKITS", "[AssemblyKitNumber] ='" & Me.txtComponent & "'")
            
           'Load all parts for possible alternates in drop down
               txtAlternateA.RowSource = "SELECT PDatabase.PartNumber " & _
                        "FROM PDatabase " & _
                        "ORDER BY PDatabase.PartNumber; "
                             If txtAlternateA.ListCount = 0 Then
                             txtAlternateA.BackColor = vbWhite
                             
                             Else
                             Me.txtAlternateA.BackColor = vbYellow
                             
                             End If
    
    
                txtAlternateB.RowSource = "SELECT PDatabase.PartNumber " & _
                        "FROM PDatabase " & _
                        "ORDER BY PDatabase.PartNumber; "
                             If txtAlternateB.ListCount = 0 Then
                             txtAlternateB.BackColor = vbWhite
                             
                             Else
                             Me.txtAlternateB.BackColor = vbYellow
                             
                             End If
    
    
                txtAlternateC.RowSource = "SELECT PDatabase.PartNumber " & _
                        "FROM PDatabase " & _
                        "ORDER BY PDatabase.PartNumber; "
                             If txtAlternateC.ListCount = 0 Then
                             txtAlternateC.BackColor = vbWhite
                             
                             Else
                             Me.txtAlternateC.BackColor = vbYellow
                             
                             End If

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

Similar Threads

  1. Change Combobox list after use it
    By TesZero in forum Programming
    Replies: 4
    Last Post: 07-22-2014, 02:14 AM
  2. Change Font Color of Selected List Box Item
    By buckwheat in forum Access
    Replies: 2
    Last Post: 06-03-2013, 03:46 PM
  3. Change field color based on result
    By dniezby in forum Programming
    Replies: 1
    Last Post: 05-01-2013, 09:43 PM
  4. Replies: 5
    Last Post: 09-18-2012, 12:39 PM
  5. Replies: 8
    Last Post: 04-26-2012, 10:13 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