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

Text Label with name of the Form 3

Status
Not open for further replies.

beckwiga

Programmer
Mar 30, 2005
70
Is this a basic question? I want to programatically create a text label on my form with the actual name of the Form. Anybody done this? Any assistance would be appreciated. This is Access 2003.
 
How are ya beckwiga . . . . .

Hvae a look at the [blue]CreateControl Method[/blue].

Calvin.gif
See Ya! . . . . . .
 
I found this...


Based on this, I can't get this to do anything. Not sure what I am doing wrong yet. If I add this code to my form and change the name of the table, i get no errors, but nothing seems to happen.

Where should I use the CreateControl? In the BeforeUpdate? Do you know if there is another way to do this?
 
beckwiga . . . . .

All ya had to do was goto VBE help in Access.

The link you provided simply shows an [blue]example[/blue] of making a form and add a control, and meant for [blue]just a guide[/blue], and [purple]it does explain all the particulars![/purple]

My question is: Is absolutely necessary to create the control?

You couldn't say . . . bring a hidden control into view?

Calvin.gif
See Ya! . . . . . .
 
Why not simply a TextBox with ControlSource set to
=Me.Name

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hey PHV .. When I try the Me.Name as the Control source for the text box, I get a #Name? I haven't tried the Access help on the CreateControl yet as Ace Man suggests, yeah, I was thinking there was probably an easier way. Occassionally I get a #Name? when trying to do stuff. What exactly does that mean? Just that Access doesn't understand what your trying to do?
 
Access doesn't like the "Me" keyword in controlsources, but it's used in coding, try just:

[tt]=Name[/tt]

- and - hopefully you don't have any control or field named "Name"...

The CreateControl function, requires the form to be in design view - so you'd need to open the form in design view, create the control, then open in form view (the sample you link to, is the same as found in the help files) - but isn't it much easier if it's possible to just use the above controlsource, or PHV's suggestion in a relevant event procedure (on current?)

[tt]me!txtFormName.value = me.name[/tt]

should work, to assign the forms name to a control called txtFormName.

Roy-Vidar
 
BTW, for a label:
Me!lblFormName.Caption = Me.Name

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Yeah, just =Name worked for me. I don't and probably will not have a Name field. So... cool, thanks a lot guys, I appreciate it.
 
Hi, beckwiga,

You most definitely should NOT have a Name field. Naming your fields/controls the same as properties of Access objects or VBA functions (name, height, date, caption would be just a few examples) can cause all sorts of headaches and should be strictly avoided.

Ken S.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top