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

Change Query Description in VBA? 3

Status
Not open for further replies.

ordendelfai

Technical User
Nov 8, 2002
187
US
Access 97

I am using code to create/change queries in VBA, and need to change the query description (property). If you know a way to change a query's description, I would really appreciate the information ;-)

~Joel
As common courtesy and to help other members who might find your thread helpful in the future, please respond if the advice given resolved your issue.
 
If it alredy has a description, and you want to alter it, you can try something like this:

[tt]currentdb.querydefs("myquery").properties("Description")="My description"[/tt]

If it doesn't have any description, the description property doesn't exist, and needs to be created (in that case, the the above would throw an exeption). Try something like this:

[tt]dim prp as dao.property
dim qdf as dao.querydef

set qdf=currentdb.querydefs("myquery")
set prp=qdf.createproperty("Description",dbText,"My New Description")
qdf.properties.append prp[/tt]

Roy-Vidar
 
This is great, I'll try it out and report back ;-)

Thanks!

~Joel
As common courtesy and to help other members who might find your thread helpful in the future, please respond if the advice given resolved your issue.
 
This works great, thanks alot!

~Joel
As common courtesy and to help other members who might find your thread helpful in the future, please respond if the advice given resolved your issue.
 
Now that this works, I am wondering if there is a way to refresh the database window. If I run code that changes Query descriptions, I currently have to click off of the Query tab, then back on to it (Access 97).

Thanks ;-)

~Joel
As common courtesy and to help other members who might find your thread helpful in the future, please respond if the advice given resolved your issue.
 
Great, thanks ;-)

Now if I could only hide queries...

Other Thread

~Joel
As common courtesy and to help other members who might find your thread helpful in the future, please respond if the advice given resolved your issue.
 
Haven't the foggiest, I've read once to prefix their names with 'usys', to "fool" Access into thinking they are system tables, which will "hide" them... (I don't know anything about possible consequences, dangers or anything, but do test it...)

Roy-Vidar
 
WOW! That actually worked!!! I just put in some IF Statements with code that loops to make it work.

db.QueryDefs(QueryName).Name = "usys_" & QueryName

That Hides it

db.QueryDefs("usys_" & QueryName).Name = QueryName

That shows it.

Thanks so much, barely required any code and works great! ;-)

~Joel
As common courtesy and to help other members who might find your thread helpful in the future, please respond if the advice given resolved your issue.
 
Actually, the "USys" thing isn't a trick--it's documented behavior. It is intended to let you hide objects as if they were system objects. There are no negative effects.(Incidentally, non-COM add-in databases must have a "USysRegInfo" table.)

As I mentioned in the other thread, Access 2000 introduced Application methods GetHiddenAttribute and SetHiddenAttribute for accessing/changing the 'hidden' attribute from VBA. I just discovered this 2 days ago.

Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
Thanx for the info RickSpr! Have one of the purple thingies.

Shows one should perhaps not just buy books, but also read them;-)

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top