Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / January 2006

Tip: Looking for answers? Try searching our database.

Verify existence of DB property

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brian - 09 Jan 2006 17:52 GMT
I am using a custom DB property to control an expiration date of a demo
version of an Access app. In order to avoid errors, though, I must first
check to see if the property exists (before I attempt to set its value).

Currently, I am enumerating the entire properties collection by looping
through numerically to see if any ...<Property#>.Name matches the name of the
property.  Would it be better to do this: If IsNull
(CurrentDB.Properties("ABC").Name) Then...

Is there any simpler/better way to just check to see if it exists?
Douglas J Steele - 09 Jan 2006 18:35 GMT
Trying to refer to a property that doesn't exist will raise an error (3270,
if memory serves) that you can trap.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> I am using a custom DB property to control an expiration date of a demo
> version of an Access app. In order to avoid errors, though, I must first
[quoted text clipped - 6 lines]
>
> Is there any simpler/better way to just check to see if it exists?
Dirk Goldgar - 09 Jan 2006 18:40 GMT
> I am using a custom DB property to control an expiration date of a
> demo version of an Access app. In order to avoid errors, though, I
[quoted text clipped - 5 lines]
> the name of the property.  Would it be better to do this: If IsNull
> (CurrentDB.Properties("ABC").Name) Then...

That last approach won't work, because it will raise an error (3270,
IIRC) if the property "ABC" doesn't exist.

> Is there any simpler/better way to just check to see if it exists?

What I usually do is refer to the property and trap the error if it
doesn't exist.  For example:

   On Error Resume Next
   varABC = CurrentDb.Properties("ABC").Value
   Select Case Err.Number
       Case 0
           ' The property exists
       Case 3270    ' ** If I remember right -- check this
           ' The property doesn't exist
       Case Else
           MsgBox Err.Description, vbExclamation, "Error " & Err.Number
   End Select
   On Error GoTo Err_Handler  ' reset to normal error-handler

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Brian - 09 Jan 2006 19:46 GMT
Thanks.

> > I am using a custom DB property to control an expiration date of a
> > demo version of an Access app. In order to avoid errors, though, I
[quoted text clipped - 25 lines]
>     End Select
>     On Error GoTo Err_Handler  ' reset to normal error-handler
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.