Consulting

Results 1 to 4 of 4

Thread: Referencing a row Textbox inside subform

  1. #1
    VBAX Regular
    Joined
    Aug 2017
    Posts
    17
    Location

    Referencing a row Textbox inside subform

    I have a loop going through each record, and comparing different values. In some cases I need to change the background color of just one text box.

    How do I reference that rows textbox? I thought I could use an index, but cannot find it. Like: Form.Row(i) or
    Me.subfrm_import_solidworks_detail.Form.Controls!nPartNumber.BackColor = vbRed

        
    Set Me!subfrm_import_solidworks_detail.Form.Recordset = rsSW    
        i = 0
        If Not (rsSW.EOF And rsSW.BOF) Then
            rsSW.MoveFirst
            Do Until rsSW.EOF = True
            
                If IsNull(rsSW.Fields("[PART NUMBER]").value) Then
                    gImportHasErros = True
                    
    ' This changes all rows, I want only the current rows, textbox
                    Me.subfrm_import_solidworks_detail.Form.Controls!nPartNumber.BackColor = vbRed
                End If
                
                'Move to the next record. Don't ever forget to do this.
                rsSW.MoveNext
                i = i + 1
            Loop
        Else
          ' MsgBox "There are no records in the recordset."
        End If
    ex.png
    Last edited by rkruis; 08-29-2017 at 06:09 AM.

  2. #2
    VBAX Regular
    Joined
    Aug 2017
    Posts
    17
    Location
    It looks like this must be done using Conditional Formatting.

  3. #3
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    Forms in Continuous mode can't change just one record's field using VBA, it changes all of them, a major glitch in MA Acceess programming. It is fine for forms in Single Form mode.
    There is a roundabout method to do so for continuous mode, but it hardly seems worth the effort when as you say you can use conditional formatting.
    If you really wanted to try the VBA method I might be able to find it for you, but I think it may only show up when you are on the record, unlike conditional formatting.

  4. #4
    VBAX Regular
    Joined
    Aug 2017
    Posts
    17
    Location
    No worries - I am OK with using conditional formatting. I just had to make some minor changes in the SQL, which ended up being a little cleaner.

Posting Permissions

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