PDA

View Full Version : [SOLVED:] Referencing a row Textbox inside subform



rkruis
08-29-2017, 05:53 AM
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


20199

rkruis
08-29-2017, 06:21 AM
It looks like this must be done using Conditional Formatting.

OBP
08-29-2017, 07:42 AM
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.

rkruis
08-29-2017, 07:52 AM
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.