VBA forms!form name!form button.property command

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hen i developed the forms in this particular database, i allowed spaces in
the form name.. ie "applications maintenance". I cannot use VBA commands
like above because i can't get the syntax to allow a space in the name. It
works when i replace the space with an underscore, but i don't want to revise
all the form names i have in the database, unless necessary.

Is there some syntax i can use to get around this.. using " does not work

Thanks

Paul
 
Hi, Paul.
hen i developed the forms in this particular database, i allowed spaces in
the form name.. ie "applications maintenance".

If you had named the form in camel case, "ApplicationsMaintenance" and set
the form's Caption Property to "applications maintenance," you'd be able to
easily read the name of the form and write code that manipulates this form.
However, Access offers a work-around that often works (and sometimes doesn't
-- so don't rely on this to keep from having to chase bugs) that you may use
in VBA. Enclose the identifier (name of any object -- such as forms, tables,
queries, fields, et cetera -- variable, or procedure) with brackets, and the
code will usually work. For example:

Forms![applications maintenance]!OKBtn.Enabled = True

And let this be a lesson that you don't want to repeat in the next database
application you create. Use the Caption Property for readability, not the
Name Property.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
perfect.. thanks

Gina Whipp said:
I belive putting brackets around the name will work.

forms![form name]![form button].property command


message news:[email protected]...
hen i developed the forms in this particular database, i allowed spaces in
the form name.. ie "applications maintenance". I cannot use VBA commands
like above because i can't get the syntax to allow a space in the name.
It
works when i replace the space with an underscore, but i don't want to
revise
all the form names i have in the database, unless necessary.

Is there some syntax i can use to get around this.. using " does not work

Thanks

Paul
 
Back
Top