Assign Current Form Name to a variable in VBA

B

BlueWolvering

Hello,
Using Microsoft Access 2003,

I would like to assign the current form's name to a variable.

So opening the VBA code for a particular form, at the top I want to

Dim strFormName as String
Set strFormName = {Current Form Name}

How does one go about this? I know that forms(X).name but I don't know
what X = for each form and I don't know if changes.

It's not like me.name is it?

Thank you
 
B

BruceM

Rather than wonder if something like Me.Name is how to go about it, just
test it. You are correct, and could have found out in less time than it
takes to post a question and await a reply.

Dim strFormName as String
strFormName = Me.Name

Having said that, I don't know quite what you mean by "at the top". where
do you want the form name to appear?
 
B

BlueWolvering

You are 100% correct. I feel a bit like a jackass on this one, but honestly
I just forgot about trying it. Also, I luckily did not wait for it, I just
kept going, and figured I'd fix it when the response came in.

I thought of me.name just as I was finishing up the post so I just tacked it
on.

Thanks for reminding me to test it. I hope I didn't waste too much of your
time.
 
B

BruceM

Not a problem for me. After all, I chose to respond. I didn't recognize
your moniker, so in case you are new I was just pointing out that there
could be a delay before you receive a response.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

reference form name 2
get a reference on a form by using form's name 5
Help explain to me 3
sendobject with False not automatically sending email 3
Dynamic Form Caption 2
Docm 2
Is form Loaded 2
SetDefault 3

Top