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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change column headings in datasheet view

Status
Not open for further replies.

OhioSteve

MIS
Mar 12, 2002
1,352
US
I have a form in datasheet style. I have noticed that each text box's label is irrelevant. You can delete the label in design view, and nothing changes in form view. The text box's name seems to become the column's header in form view.

Now, I want to change the column heading WITHOUT changing the text box's name. I understand that I will need to do this in VBA. Can you get me started on the code?
 
To set the caption names you do this in the table design view. If the field name is "strLastName" set the Caption to "Last Name". It will appear on all datasheet views. If you want to do it dynamically, I do not think it would be easy because the Caption is a property of the table or qery.
 
How are ya OhioSteve . . .

[blue]You loose alot of form functionality in datasheet view![/blue]

A continuous form can be made to look just like a datasheet, [blue]while retaining full form functionality . . .[/blue]

Calvin.gif
See Ya! . . . . . .
 
I had to do this once, and it drove me in sane trying to figure it out. I got the anser here, although I can't remember who gave it.

The trick is kinda simple really. When you make your form, make a non data sheet form. That way, the labels are "attached" to the data fields.

Then, after your form is built, change the default view of the form to data sheet.

Once done, it opens as data sheet, and changing the caption field of the fields Label, changes he heading in the datasheet.

You need to know the name of the label for you column field to change it with VBA, and access assignes it a name like label1, 2, 3...

Either way, vba code like

me!label1.caption = "Hello World" will work, even when the form is open.

Hope this is useful. It saved my life once upon a time.

ChaZ

There Are 10 Types Of People In The world:
Those That Understand BINARY And Those That Don’t.
 
Blorf,

I appreciate your suggestion but it did not work for me. I let the wizard make a continous form. THEN, I changed it to a datasheet. I put this code into the form's "on open" "on load" and "on current" properties....

PayPeriodID_Label.Caption = "hello world"

It never really changed the caption.
 
AceMan,

I like your continous form idea. I have made a continous form that resembles a datasheet. I used format/align/right to scrunch the fields together. However, even THAT technique did not create perfect gridlines like a datasheet.

So do you know a better scruching technique?
 
OhioSteve . . .

Apparently your fixated with datasheet view.

You can sizs all the texboxes the same and reposition them to maintain the view.
OhioSteve said:
[blue] even THAT technique did not create [purple]perfect gridlines[/purple] like a datasheet.[/blue]
Just what are [purple]perfect gridlines[/purple]?

Calvin.gif
See Ya! . . . . . .
 
Hi.

Make sure your labes and objects are both in the form's detail. If they are in the header, they are not bound to the object.

Continious makes the form just like data sheet.

ChaZ

There Are 10 Types Of People In The world:
Those That Understand BINARY And Those That Don’t.
 
OhioSteve,
Am I missing something here? You want to use a datasheet, but you want the labels to be something other than the field name. Why can you not just set the caption property in the table design view? Do these labels need to change dynamically? This is really the purpose of field caption property.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top