You are here:

Using MS Access/Get field name from a subform

Advertisement


Question
Subform
Subform  
Hi Scottgem,

Here's my problem, I have a subform.. what I want is whenever i select a record the field name should appear on a textbox. Its like status bar but on a form. You will notice on the image the column sizes is small because users are just going to input numbers and I don't it to take so much space. I want the user to have a clue on what is the current selected field/column. How do i accomplish that?

Thank you
Hudas

Answer
My recommendation is to NOT use Datasheet view. Use a continuous form for the subform. Then you make your labels on multiple lines or you can stagger the labels over multiple rows. For example:

label1   label3
    label2

I almost never use datasheet view because its so limiting.

But if you still want to do it your way. Put a textbox on the main form and name it txtCurrent. Then in the Gotfocus event of each control on the subform use the Code Builder to enter this line of code:

Forms!mainformname!txtCurrent = Screen.ActiveContol.Caption

Hope this helps,
Scott<>
Blog: http://scottgem.wordpress.com
Website: http://www.diamondassoc.com
Microsoft Access MVP 2007
Author: Microsoft Office Access 2007 VBA

Using MS Access

All Answers


Answers by Expert:


Ask Experts

Volunteer


Scottgem

Expertise

I can answer almost all types of questions relating to Microsoft Access usage and application design. My strengths are database and interface design.

Experience

I've been designing databases for over 25 years working with dBase, FoxPro, Approach and Access.

Organizations
Author of Microsoft Office Access 2007 VBA
Techncial Editor for Special Edition Using Microsoft Access 2007 and Access 2007 Forms, Reports & Queries From Que Publishing

Education/Credentials
Brooklyn College BA

©2016 About.com. All rights reserved.