I thought I understood continuous forms, but this I don’t understand:
I have VBA code which successfully does the following
-The user double-clicks a field of a current record on a continuous form. This makes a subform visible.
-The date field on the subform gets populated with a date from the main form current record.
-The focus moves to the date field on the subform.
The code is:
Private Sub TimeB_DblClick(Cancel As Integer)
1.
Me!sbfSUBFORM.Visible = True
2.
Me!sbfSUBFORM.Form!EventDate = Forms!frmMAIN!EventDate
3.
Me!sbfSUBFORM.SetFocus
4.
Me!sbfSUBFORM.Form!txtEventDate.SetFocus
(Note: For whatever reason, it’s taking two lines, 3 & 4, to set the focus on the field in the subform.)
On the main form, other than an arrow “►”, the current record is not obvious.
So I wanted to change the backcolor of the fields on that current record.
I tested this using the EventDate field and just adding line 2.1:
1.
Me!sbfSUBFORM.Visible = True
2.
Me!sbfSUBFORM.Form!EventDate = Forms!frmMAIN!EventDate
2.1 Forms!frmMAIN!EventDate.BackColor = RGB(255, 255, 0)
3.
Me!sbfSUBFORM.SetFocus
4.
Me!sbfSUBFORM.Form!txtEventDate.SetFocus
The problem is that line 2.1 changes the backcolor of the EventDate field on the NewRecord line, not on the current record.
Could someone please explain why
“Forms!frmMAIN!EventDate”
will successfully return the current record’s date, but using a similar reference
“Forms!frmMAIN!EventDate.BackColor = RGB(255, 255, 0)”
Changes the color of the field in the new record rather than the field in the current record**.**
Thank you.