4

We have a form in MS-Access which can be viewed either in form or datasheet mode.

The form is arranged in such a way that labels aren't required for some of the textboxes.

In datasheet mode however, some kind of column heading is required and the default behaviour which takes the control name (as in txtRetailPrice) is really ugly.

Is there a way to set the datasheet column header text without putting labels on the underlying form. As I've said, the form is nicely laid out and adding labels in there would actually be confusing.

I'm hoping there is a solution preferably which doesn't involve adding redundant labels to the form.

hawbsl
  • 15,313
  • 25
  • 73
  • 114
  • 3
    How about hidden labels? – Fionnuala Feb 09 '11 at 13:51
  • is that the only way? if so, i'll accept it as an answer if you want to upgrade your comment – hawbsl Feb 09 '11 at 14:00
  • I put it as a comment because it is the only way I can think of, but I do not want to tread on your chances of another answer, though I do not think there is one. However, let's hang on a little to see. – Fionnuala Feb 09 '11 at 14:28
  • Outside of changing the name of the control itself, hidden labels seem to be the cleanest solution. – mwolfe02 Feb 09 '11 at 15:26
  • Just to confirm hidden label controls as the only solution, if you open a datasheet (or open a form and switch to datasheet view), and check the Intellisense on `Screen.ActiveDatasheet.ActiveControl` you'll see that there's no way to do this except via the Controls collection (`Screen.ActiveDatasheet.ActiveControl.Controls(0).Caption`), and if there's no label attached, the Controls collection will be empty. – David-W-Fenton Feb 12 '11 at 00:15
  • @DWF thanks for your confirmation – hawbsl Feb 12 '11 at 22:10

3 Answers3

15

I know this is an old post and your question was already answered, but my answer might be helpful to you.

You didn't mention your version of Access, but in Access 2010 there's a textbox property called Datasheet Caption. When you insert a space as a value for this property, the column header in your datasheet will show up blank. Hope this helps.

Barry
  • 166
  • 1
  • 3
  • thanks, we're not using A2010 at the moment but will be moving to it, so i'll bear your tip in mind – hawbsl Oct 10 '11 at 19:30
  • I determined from bMac's answer that this was available in the control's property and used it through the property window as you answered here. To be fair however bMac gave a strictly programmatic approach so I up voted both. Thanks you two. – Anthony Griggs May 14 '15 at 02:39
8

Since 'Datasheet Caption' shows up as a Design option, there is a property. Simply set the textbox property:

tBox.Properties("DataSheetCaption") = "Whatever you want it to say"
kleopatra
  • 51,061
  • 28
  • 99
  • 211
bMac
  • 81
  • 1
  • 2
1

Hidden labels seems to me to be the best solution. It will keep your form clean and display the headings you want.

Fionnuala
  • 90,370
  • 7
  • 114
  • 152
  • accepted. thanks. i think i see what you mean by "clean", as in clean to the end user. pretty messy for the developer to look after though, and not all clean to look at in design mode. just grumbling at access not trying to shoot the messenger. – hawbsl Feb 12 '11 at 21:49
  • @hawbsl you can make them quite small and stack them neatly in a corner, but yes, the form will not be quite what you want in design view. – Fionnuala Feb 12 '11 at 21:56
  • 1
    Something that I started doing some time ago that makes it easier to work with hidden controls is that I chose a particular background color that I'm very unlikely to ever use on an actual form, and set the background of all hidden controls to that color (I happen to use bright yellow). With these background colors set, I can tell at a glance in design view which controls are hidden. – David-W-Fenton Feb 13 '11 at 00:29