473,399 Members | 3,603 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Editing object description properties with VBA

I created a routine to read and edit the description properties of
tables, (the one you see in the database window). It works just fine.
This is the basic code behind it, I substituted all my
editing/updating code with the debug.print to keep it simple.

Function EditTableDescriptions()
On Error GoTo Err_EditTableDescriptions

Dim db As DAO.Database
Dim tbl As DAO.TableDef
Dim prp As DAO.Property
Dim NoDescription As Boolean
Dim DescriptionText As String
Dim TableNameText As String

Set db = CurrentDb

For Each tbl In db.TableDefs
NoDescription = False
Set prp = tbl.Properties("description")
If NoDescription Then
Debug.Print "Table: " & tbl.Name
DescriptionText = "No Description"
TableNameText = tbl.Name

Else
Debug.Print "Table: " & tbl.Name & " - " & prp.Value
DescriptionText = prp.Value
TableNameText = tbl.Name

End If
Next

Exit_EditTableDescriptions:
db.Close
Exit Function

Err_EditTableDescriptions:
If Err.Number = 3270 Then
NoDescription = True
Resume Next
Else
MsgBox Err.Description
Resume Exit_EditTableDescriptions
End If
End Function

Now, I am trying to do the same qith the queries:

Function EditQueryDescriptions()
On Error GoTo Err_EditQueryDescriptions

Dim db As DAO.Database
Dim qry As DAO.QueryDef
Dim prp As DAO.Property
Dim NoDescription As Boolean
Dim DescriptionText As String
Dim QueryNameText As String

Set db = CurrentDb

For Each qry In db.QueryDefs
NoDescription = False
Set prp = qry.Properties("description")
If NoDescription Then
Debug.Print "Query: " & qry.Name
DescriptionText = "No Description"
QueryNameText = qry.Name

Else
Debug.Print "Query: " & qry.Name & " - " & prp.Value
DescriptionText = prp.Value
QueryNameText = qry.Name

End If
Next

Exit_EditQueryDescriptions:
db.Close
Exit Function

Err_EditQueryDescriptions:
If Err.Number = 3270 Then
NoDescription = True
Resume Next
Else
MsgBox Err.Description
Resume Exit_EditQueryDescriptions
End If
End Function

My problem is with the second procedure. If there is no existing table
descriptions, it grabs the correct query descriptions. If there are
existing query descriptions AND table descriptions, it grabs the
correct query descriptions. But, if there is no existing query
description , it grabs the first existing table description.

I obviously have something in the wrong sequence, or a wrong variable,
or something. I am relatively new to this, so I could use some help
here.

I promise to learn something from this, not just copy and paste a code
fix!

Thanks in advance, Dennis
Nov 13 '05 #1
2 7721
Hi Dennis

I think your observation is correct, that if a query has not description,
but it is based on a table that does have a description, Access lies and
returns the Description of the table as the Description of the query.

Makes no sense to me. There are actually many cases where Access tries to be
too helpful and just muddies the waters.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Dennis Ruppert" <dr******@ruppertweb.com> wrote in message
news:f7**************************@posting.google.c om...
I created a routine to read and edit the description properties of
tables, (the one you see in the database window). It works just fine.
This is the basic code behind it, I substituted all my
editing/updating code with the debug.print to keep it simple.

Function EditTableDescriptions()
On Error GoTo Err_EditTableDescriptions

Dim db As DAO.Database
Dim tbl As DAO.TableDef
Dim prp As DAO.Property
Dim NoDescription As Boolean
Dim DescriptionText As String
Dim TableNameText As String

Set db = CurrentDb

For Each tbl In db.TableDefs
NoDescription = False
Set prp = tbl.Properties("description")
If NoDescription Then
Debug.Print "Table: " & tbl.Name
DescriptionText = "No Description"
TableNameText = tbl.Name

Else
Debug.Print "Table: " & tbl.Name & " - " & prp.Value
DescriptionText = prp.Value
TableNameText = tbl.Name

End If
Next

Exit_EditTableDescriptions:
db.Close
Exit Function

Err_EditTableDescriptions:
If Err.Number = 3270 Then
NoDescription = True
Resume Next
Else
MsgBox Err.Description
Resume Exit_EditTableDescriptions
End If
End Function

Now, I am trying to do the same qith the queries:

Function EditQueryDescriptions()
On Error GoTo Err_EditQueryDescriptions

Dim db As DAO.Database
Dim qry As DAO.QueryDef
Dim prp As DAO.Property
Dim NoDescription As Boolean
Dim DescriptionText As String
Dim QueryNameText As String

Set db = CurrentDb

For Each qry In db.QueryDefs
NoDescription = False
Set prp = qry.Properties("description")
If NoDescription Then
Debug.Print "Query: " & qry.Name
DescriptionText = "No Description"
QueryNameText = qry.Name

Else
Debug.Print "Query: " & qry.Name & " - " & prp.Value
DescriptionText = prp.Value
QueryNameText = qry.Name

End If
Next

Exit_EditQueryDescriptions:
db.Close
Exit Function

Err_EditQueryDescriptions:
If Err.Number = 3270 Then
NoDescription = True
Resume Next
Else
MsgBox Err.Description
Resume Exit_EditQueryDescriptions
End If
End Function

My problem is with the second procedure. If there is no existing table
descriptions, it grabs the correct query descriptions. If there are
existing query descriptions AND table descriptions, it grabs the
correct query descriptions. But, if there is no existing query
description , it grabs the first existing table description.

I obviously have something in the wrong sequence, or a wrong variable,
or something. I am relatively new to this, so I could use some help
here.

I promise to learn something from this, not just copy and paste a code
fix!

Thanks in advance, Dennis

Nov 13 '05 #2
Allen

Interesting. Can I assume that you do not see anything incorrect in my
code, and that it is just a "Microsoft thing"?

Thanks,

Dennis

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Olivier Jullian | last post by:
Hi, I'm new to .NET and am trying to take advantage of the object structure while accessing relational databases. I started a small project for managing "projects". Here is a description of...
3
by: Gerry Abbott | last post by:
Access allows all objects, tables, forms, queries, macros, modules, to be documented with common object properties, including Description, Type, modified and created dates, owner, and some...
0
by: Empire City | last post by:
I have an ASP.NET form with a DataGrid and Button. I want to put a RadioButtonList in a DataGrid cell. I bind it to an ArrayList which has a ListItem in the cell. The display part works fine. I...
2
by: Martin Hazell | last post by:
For various reasons, I have had to produce a quick (!) page to edit one column of data in a database with ASP.net. With this being my first foray into ASP.net, I apoligise for any basic erros I have...
9
by: tshad | last post by:
Is there a way to use your own image in place of the automatic one that ASP uses when doing editing in your DataGrid pages? We already have a style of button we are using and would like to be...
3
by: Patient Guy | last post by:
Subject line would seem to say it all: How does one trigger the execution of a method within an object or any other code/function with the setting of an object property? More elaboration for...
5
by: =?Utf-8?B?QWRhciBXZXNsZXk=?= | last post by:
Hi All, I have a GridView inside the EditItemTemplate of a FormView. Both FormView and GridView are data bound using an ObjectDataSource. When the FormView's ObjectDataSource object has a...
3
by: Froefel | last post by:
Hi group I am creating a web application that uses a simple DAL as an ObjectDataSource. To retrieve data from the database, I use a DataReader object from which I then assign the various fields...
4
by: Bob Darlington | last post by:
I'm using the following code to try to change a caption property for a field in a table. Dim dbs As Database, fld As Field, fFormat As Property Set dbs = OpenDatabase(CurrentDataFile) Set fld =...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.