Share via

Continuous Form, Current Record Reference

Anonymous
2011-11-08T22:32:18+00:00

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.


Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

HansV 462.6K Reputation points
2011-11-08T22:55:28+00:00

A continuous form contains a single set of controls. Changing properties of those controls, except for those related to the record source of the form, will not work the way you want.

There are methods for highlighting the current record in a continuous form, see for example http://www.upsizing.co.uk/Art53_Highlight.aspx,

Was this answer helpful?

0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2011-11-09T01:55:47+00:00

    Exactly what I needed.  Thanks!

    Was this answer helpful?

    0 comments No comments