Assign Current Form Name to a variable in VBA

  • Thread starter Thread starter BlueWolvering
  • Start date Start date
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
 
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?
 
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.
 
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.
 
Back
Top