Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Referencing a Continuous Form Field Where Cursor Resides

Status
Not open for further replies.
May 7, 1999
130
0
0
US
I've searched high and low and I know there's an easy answer, but it's eluding me.

I have a wide continuous form with lots of fields and want to create an "editing window" that will reflect two things: the name of the field that the cursor's positioned at on whatever row is current and the value of that field. Why? Well, the client wants to have a spreadsheet-like continuous form that contains updateable fields. Only problem is that the "spreadsheet" is so wide that the a number of the fields have to be narrowed to the point that seeing the whole value is possible only with one of the following techniques:
1. Using shift-F2 to open a separate window that can be edited,
2. Deepening the fields so that with text wraps around onto additional lines, or
3. Creating an "editing window" a la Excel that contains a "synchronized value" with the contents of the current field on the current row of the continuous form (the editing window resides in the header portion of the continuous form).

So, the object is to create a window whose value is tied to the field where the cursor resides at any given time in the continuous form and to show the name of that field (kind of like giving the row/column coordinates or name of the selected field in Excel).

I also have to handle the case where I don't want the editing window to show any value when the cursor field is, for example, a check-box instead of a text box.

How do I reference the name of the current field? Ideally, the current field would contain the name of the heading value above the detail data in the continuous form. (I never am quite sure where I start looking in Access’ help for things like these attributes of a field and the proper way to reference them. Ugh!)

Thanks,

John

John Harkins
 
Hallo,

It's a bit tricky, but there are various Control Events which may help you keep track of where you are. I'd suggest creating a function which takes a string parameter to populate the 'editing box', something like:
Code:
Public Function DisplayFieldToEdit(ByVal pstrFieldName As String) 'This is a function so it can be called from an event. It returns no value
  Forms!frmSpreadsheet!txtFieldName = pstrFieldName
  Forms!frmSpreadsheet!txtFieldValue = Forms!frmSpreadsheet(strFieldName)
End Function
In each control's OnEnter and OnExit property put:
Code:
=DisplayFieldToEdit("ControlName")
Let us know if that halps,

- Frink
 
Screen.ActiveControl.Name gives you the name of the control that has the focus

Screen.PreviousControl.Name gives you the name of the control that had the focus (this is what you should use if you click a command button)

Good luck





[pipe]
Daniel Vlas
Systems Consultant

 
WOW! I can hardly wait to try out these good ideas. Thanks.

John Harkins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top