Results 1 to 11 of 11
  1. #1
    Join Date
    Apr 2003
    Posts
    42

    Unanswered: Database Properties....

    I am looking to store the version number of a database somewhere in the database and wish to access and change this later in code.

    At first I was going to create a table to store this info, but then wondered if I could use the Database Properties.

    ie. File -> Database Properties -> [TAB] Custom

    After searching all my resources I can't find a way to access these custom variables in code.

    Anyone know a way to use these variables, or is it best to create another table to store them?

    Thanks

  2. #2
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    what are you planning to do with the version number? normaly you wouldn't need to do anything with it

    anyhow i'm sure you could abapt the following code to your need
    Sub SetStartupProperties()
    ChangeProperty "AllowBypassKey", DB_BOOLEAN, False
    End Sub

    Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
    Dim dbs As Object, prp As Variant
    Const conPropNotFoundError = 3270

    Set dbs = CurrentDb
    On Error GoTo Change_Err
    dbs.Properties(strPropName) = varPropValue
    ChangeProperty = True

    Change_Bye:
    Exit Function

    Change_Err:
    If Err = conPropNotFoundError Then ' Property not found.
    Set prp = dbs.CreateProperty(strPropName, varPropType, varPropValue)
    dbs.Properties.Append prp
    Resume Next
    Else
    ' Unknown error.
    ChangeProperty = False
    Resume Change_Bye
    End If
    End Function
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  3. #3
    Join Date
    Apr 2003
    Posts
    42

    Dunno if that's it?

    I have used the menu options:

    File -> Database Properties [TAB] Custom

    and created my own Property as such:

    Name: Version
    Type: Text
    Value: 5.2.1

    When I played with your code example, it gave me a current version number of 4.0. Not the custom property 5.2.1

    I assume this is the version number of Access not my custom database.


    I am using this custom db version number to control future database updates, so that the user can use a later version and automatically update their data from a previous version accurately.

    Thanks for the comments, I may have just missed your point but I don't think it will allow me to access my custom properties.

    Any more suggestions?

    Thanks

  4. #4
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    I think it probably will you just need to know how to they're refferenced, but it would be easier using this code to create, set and retreive the property

    as for the access versions AXP = 10, A2K = 9, A97 = 8
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  5. #5
    Join Date
    Apr 2003
    Posts
    42

    It doesn't matter which version of Access...

    I am not trying to establish which version of Access the user has.

    I am trying to create a variable that will store the Version number of the custom database I have created.

    --------------
    Eg.

    User has the first version of the database (version 1.0.0)

    I make some changes to the database forms and tables and give this version to the user. The user can now click a button, to update the new database (version 2.0.0) with the data from the older version by specifying the location of the database.

    Behind the code that does the updating (ie. copies the relevant Old data from Database Version 1.0.0 to version 2.0.0), I want to check the version number so that the appropriate data is updated and allocated to the appropriate new data fields.

    To do this, I wish to use the "Custom Database Properties" and create a property called Version.
    -------------

    I can't find any code or ways to access this custom info.


    I think I will just create a table (or a global constant) to store this info instead.

    Like:

    Table: tblVersion
    Field: Version

  6. #6
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820

    Re: It doesn't matter which version of Access...

    misunderstanding i was pointing out that the version numbers are 8,9,10 not 4 so what ever that 4 was it wasn't the access version number

    what i was suggesting is doing the following

    Sub SetStartupProperties()
    ChangeProperty "myKey", DB_TEXT, "a key"
    End Sub

    then if you put this in the VB immediate window
    ?currentdb.Properties("mykey")

    the out put is
    "a key"

    which means that if you can find out the right name you can use my code to change it, currentdb.Properties("mykey") to retreve. or you can just create it in the code
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  7. #7
    Join Date
    Apr 2003
    Posts
    42

    IC

    Thanks for the explanation.

    Cool. I may take that approach and control the property all in code. I'd prefer to be able to specify it in the DataBase Properties Window, but thus far I have no idea how to access it via code.

    Thanks for the explanation. I had seen this approach taken in the Northwind examples, but didn't all click. I hate having to use the :

    On Error Go To... approach to controlling how the app will deal with creating the property if it does not already exist.

    Unfortunately, in "Structured Programming" studies I had 'Don't use GOTO etc' drilled into me, but this was more in regards to Procedural Programming rather than Obj Driven.

    Enough banter.

    Thanks for your help.

  8. #8
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    VB is a b*st*rd language that is C++ crossed with QBasic, the result is that it is about the only langueage that still has the goto statement avalable to the coder most oo langueages use event handlers for the error handing
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  9. #9
    Join Date
    Apr 2003
    Posts
    42

    The "Right" way

    So when u r writing code in VB do u do your best to avoid the GOTO or what?

    From some examples I have seen, even in the Northwind DB I usually find a way to avoid the GOTO etc but in the process set a lot of new tests to error check everything before there is a chance of an error.

    What's the 'standard' practice in VB?

    It's a very broad question, but u may have more experience than me...

  10. #10
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820

    Re: The "Right" way

    I don't know what the standard is but i avoid goto unless there is no other way unforchantly it IS the only way to do error checking

    mind you if you thought moveing from procedural to OO was bad have a look at an example of a fuctional language www.haskell.org
    Last edited by m.timoney; 08-07-03 at 14:57.
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  11. #11
    Join Date
    Aug 2003
    Posts
    1
    Vent-

    To access custom properties tab in dba use:

    Public Function getVersionInfo() As String

    Dim v As Variant
    Dim vDte As Variant
    Dim db As Database, cnt As Container
    Dim doc As Document

    Set db = CurrentDb
    Set cnt = db.Containers!Databases
    Set doc = cnt.Documents!UserDefined

    Set v = doc.Properties("version")
    Set vDte = doc.Properties("versiondate")


    getVersionInfo = v & " - " & vDte


    End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •