Application Title

E

Eli

Does anyone know if there is a way to change the caption of the main Access
window via VBA?

I know we can set a title via the Tool, Startup screen, but I need to
manipulate this via code so that it can reflect the different values as I
need them to show up.

Thanks in advance for the help.
 
G

Graham R Seach

Eli,

My son's name is Eli. You don't see that name too often.

The following procedure shows how to do it. You first have to create the
property, because although you can see it in the Startup dialog, it doesn't
exist until you put a value in it. Then the example shows you how to
retrieve its value, and change its value once it's been created.

Dim prp As Variant
Dim db As database

Set db = CurrentDb
On Error Resume Next

'Create the new property
Set prp = db.CreateProperty("AppTitle", DB_TEXT, "abc")
If Err <> 0 Then db.Properties.Append prp

'Print it out
Debug.Print db.Properties("AppTitle")

'Now change it again
db.Properties("AppTitle") = "xyz"
Debug.Print db.Properties("AppTitle")

Set prp = Nothing

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html
 
E

Eli

Hi Graham, thanks for responding...and you're right, Eli is not a name you
see too often out there.

I think I probably needed to mention that I am working with an Acesss ADP
file connected to a SQL Server database.

The line that had "db.CreateProperty" failed saying that
CreateProperty is not a method of db...I get the feeling db is used for
MDB's, but 'm not sure.

Also of note...I have actually entered a value in the Startup dialog for the
app title, so I don't know if this makes a difference.

I really do appreciate your help with this because I couldn't find anything
in the help file.

Thanks again.
 
G

Graham R Seach

Eli,

Oh, OK, and ADP. In that case, use this:

On Error Resume Next

'Create the new property
CurrentProject.Properties.Add "AppTitle", "abc"

'Print it out
Debug.Print CurrentProject.Properties("AppTitle")

'Now change it again
CurrentProject.Properties("AppTitle") = "xyz"
Debug.Print CurrentProject.Properties("AppTitle")


Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html
 
E

Eli

Hi Graham, thanks for the info.

This code is clear to me now, I totally understand what is happening. And
it didn't crash, so the custom property and its value are deifnitely part of
the project now.

The only thing I don't see here in the code is the part that actually
changes the caption of the main Access window to this new value we are
assigning to the custom property.

What I'm looking to do is display the name of the user's company in the main
Access window, and the name of their company is stored in a table. So once
they open the app, I want to run some code that will retrieve the name of
their company from the tblCompany table, and display it in the main Access
window caption.

As an example, for a form, I could easily put this code in the Open event of
the form and the caption would change:

Me.Caption = "Graham's Form"

But I cannot find a way to do this for the main Access window caption. And
by the way, I'm running this with the Access 2003 runtime.

I'm sorry if I didn't make this clear from the beginning...I hate to take up
so much of your time with this.

Again, I appreciate the help very much. This will make for a slick little
feature for the app.

Take care.
 
E

Eli

OK!

That worked perfectly!

I will be purchasing your book because I'm sure there's a lot of information
I need to know in there.

Thanks again very, very much for the help Graham.

Take care.
 
J

Jeff Conrad

May I ask the stupidest question of the year (one I've been trying to figure out for weeks)?
Is that you on the cover or is that Armen?
(If I may ask)
 
G

Graham R Seach

It's Armen. They "forgot" to put my photo on the cover.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------
 
T

Tom Wickerath

Hi Jeff,

That's Armen, at least on my copy of the book. He's the past president of one of our local
Access groups (PNWADG).


Tom
_________________________________________


May I ask the stupidest question of the year (one I've been trying to figure out for weeks)?
Is that you on the cover or is that Armen?
(If I may ask)
 
J

Jeff Conrad

Ohhh that hurts!
I'll write to the publisher for you.
;-)

BTW, I cannot get past the Appendices yet.
Those are packed with great info!
 
J

Jeff Conrad

Hi Tom,

I was not sure so I thought I might ask. Curiosity got the best of me.
Maybe I should start the Central Oregon Access Users Group (COAUG).
:)
 
6

'69 Camaro

Hi, Jeff.

My Mom lives in Southern Oregon and she'd like me to come live near her. To
help convince me to move there, she told me that I could work at the local
college in Ashland and start a local computer user group. It would be
called "Southern Oregon Database Users and Hackers" (SODUH) -- pronounced
"so, duh!"

Oh, that would look great on my resume, Mom!

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.)
 

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

Top