Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 34
  1. #16
    Monty51 is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    48

    Thanks for your input. Had I written this application, I can only hope I would have put some debugging options in.

  2. #17
    Monty51 is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    48
    Here's the code for "On Load", "On Open", and "On Timer":

    Private Sub Form_Load()
    On Error GoTo Form_Load_Err ' Add-in Tool

    If CurrentUser() <> "acadmin" Then
    Me.ShortcutMenu = False
    End If

    Form_Load_Exit: ' Add-in Tool
    DoCmd.SetWarnings True ' Add-in Tool
    DoCmd.Hourglass False ' Add-in Tool
    DoCmd.Echo True ' Add-in Tool
    Exit Sub ' Add-in Tool

    Form_Load_Err: ' Add-in Tool
    MsgBox Err.Description ' Add-in Tool
    Resume Form_Load_Exit ' Add-in Tool

    End Sub

    Private Sub Form_Open(Cancel As Integer)
    On Error GoTo Form_Open_Err ' Add-in Tool
    Me.TextVersion.Requery
    Me.Repaint
    Call EnableCloseButton(False)

    Form_Open_Exit: ' Add-in Tool
    DoCmd.SetWarnings True ' Add-in Tool
    DoCmd.Hourglass False ' Add-in Tool
    DoCmd.Echo True ' Add-in Tool
    Exit Sub ' Add-in Tool

    Form_Open_Err: ' Add-in Tool
    MsgBox Err.Description ' Add-in Tool
    Resume Form_Open_Exit ' Add-in Tool

    End Sub

    Private Sub Form_Timer()
    On Error GoTo Err_Form_Timer
    DoCmd.OpenForm "frm Password"

    Exit_Form_Timer:
    Exit Sub

    Err_Form_Timer:
    MsgBox Err.Description
    Resume Exit_Form_Timer

    End Sub

    (I tried indenting to make things clearer, but it didn't take)

    This code is from the opening form ("Frm Welcome") which serves to display the program name, ownership, and version information.

    It doesn't do too much except set a few things and then a few more if the current user is "acadmin". The "On Timer" value is 3 seconds, if I read that property correctly, and keeps the form open for that time as a splash screen (things might be going on in the background; I can't tell) before it opens a different form (a login screen).

    I've narrowed my first error down to a routine that's supposed to set an "AppVersion" variable when this form opens. It doesn't for reasons I can (currently) only guess are related to differences between Access 97 and 2016. The routine to set the AppVersion variable uses some db.Properties statements and values that Access 2016 doesn't like for some reason. Here's that code:

    Public Function AppVersion(Optional SetAppVersion As Variant) As String
    On Error GoTo Err_AppVersion

    Dim db As Database
    Dim prpUserDefined As Property

    Set db = CurrentDb
    Set prpUserDefined = db.Properties("AppVersion")
    If IsMissing(SetAppVersion) Then ' If no value sent the return value of property
    AppVersion = prpUserDefined.Value
    Else ' Else set property to new value
    prpUserDefined.Value = SetAppVersion
    db.Properties.Refresh
    AppVersion = prpUserDefined.Value
    End If
    db.Close
    Set db = Nothing

    Exit_AppVersion:
    Exit Function
    Err_AppVersion:
    MsgBox Err.Description, vbCritical
    Resume Exit_AppVersion

    End Function

    I don't have sufficient literature on either version of Access (I'm working on it, and suggestions are gratefully appreciated). I probably jumped the gun by posting any questions here until I was better-read, but I was hoping there was something obvious I'm missing.

    Thanks for looking

  3. #18
    Monty51 is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    48
    Sigh...these replies are not posting where I thought they would. Sorry for the confusion.

  4. #19
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    You can make indenting in your code stick by use code tags, the # icon in the reply area.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #20
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,939
    To preserve indenting, highlight you code and click the # button

  6. #21
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,880
    Do you have any idea what this procedure is for?
    It appears to be setting a database property. Is there ever a value SetAppVersion passed to the function?

    I also think this db.Properties("AppVersion") should be db.Properties("Version") but i'm not positive.

    Is the timer interval set to 3 or 3000? 3000 is 3 seconds.

    Code:
    Public Function AppVersion(Optional SetAppVersion As Variant) As String
        On Error GoTo Err_AppVersion
    
    
        Dim db As Database
        Dim prpUserDefined As Property
    
    
        Set db = CurrentDb
        Set prpUserDefined = db.Properties("AppVersion")
        If IsMissing(SetAppVersion) Then    ' If no value sent the return value of property
            AppVersion = prpUserDefined.Value
        Else    ' Else set property to new value
            prpUserDefined.Value = SetAppVersion
            db.Properties.Refresh
            AppVersion = prpUserDefined.Value
        End If
        db.Close
        Set db = Nothing
    
    
    Exit_AppVersion:
        Exit Function
    Err_AppVersion:
        MsgBox Err.Description, vbCritical
        Resume Exit_AppVersion
    
    
    End Function
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  7. #22
    Monty51 is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    48
    Quote Originally Posted by moke123 View Post
    The first things I would do are those suggested by Ajax, Option explicit and error handling.
    What code runs in your open event and timer events?
    Try commenting out code to see where the error may be.
    Quote Originally Posted by isladogs View Post
    Error 3270 (property not found) occurs if you try to set the value of a property which doesn't exist.
    I would strongly recommend you don't just use On Error Resume Next in your procedures (as suggested in post #2) as it will effectively suppress all errors without you being aware of them.

    A safer alternative is to handle that specific error as part of your error handling routines. For example:

    Code:
    Public Sub UpdateLinkedTables()
    
    On Error GoTo Err_Handler
    
    ...Your code goes here...
    
    Exit_Handler:
        Exit Sub
    
    
    Err_Handler:
        If Err.Number = 3270 Then 'property not found
            Resume Next
        Else
            MsgBox "Error " & Err.Number & " in UpdateLinkedTables routine :" & vbCrLf & "  - " & Err.description
            Resume Exit_Handler
        End If
    
    
    End Sub
    I will follow your suggestion (On Error Resume) when I get to writing my own routines. I'm not sure if I mentioned that I'm converting an Access 97 app to Access 2016. Everything's written, I just have to fix the things that break due to the difference in versions of Access.

    Also, unfortunately the person who wrote this app originally has passed away and didn't leave any documentation, so that's also what I'm up against.

    Thanks for looking.

  8. #23
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,880
    Out of curiousity type the following lines one at a time in the immediate window

    ?currentdb.Properties("Version")
    ?currentdb.Properties("appVersion")

    I think "appVersion" will error
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  9. #24
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,569
    @Moke123
    I mentioned db properties in post 3, and gave OP code to list them all in post 7?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  10. #25
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,880
    Quote Originally Posted by Welshgasman View Post
    @Moke123
    I mentioned db properties in post 3, and gave OP code to list them all in post 7?
    Yea, I know but he never posted the results.
    I used that code and saw that the actual property is "Version", not "appVersion".

    I'm wondering if the original author added a custom property "appVersion" and when the OP imported everything into a new DB he didn't add that custom property.
    I doubt it would transfer over with an import.
    edit: Note that the version property refers to the access version. I think appVersion was added by the original author to show the version of the application.

    I think OP is under the impression it's setting a variable when it is setting a db property.
    I've narrowed my first error down to a routine that's supposed to set an "AppVersion" variable when this form opens.
    this line is probably the error
    Code:
    Set prpUserDefined = db.Properties("AppVersion")
    It's not finding that property because it does not exist in the new database.

    OP needs to run a CreateProperty() procedure
    Last edited by moke123; 08-24-2021 at 12:32 PM.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  11. #26
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,880
    If the above is correct then something like this may fix it.

    Code:
    Function CreateDBProperty(PropName As String, intType As Integer, PValue As String)
        Dim db As DAO.Database
        Dim P As Property
        Set db = DBEngine(0)(0)
        Set P = db.CreateProperty(PropName, intType, PValue)
        db.Properties.Append P
    End Function
    
    
    Sub AddMyProperty()
        Call CreateDBProperty("appVersion", dbText, "appVersion 2.0 " & Year(Now))
    End Sub
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  12. #27
    Monty51 is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    48
    Seeing as there is much to learn, I'm going to consider this thread over and done with. My thanks to the many that took a look and tried to help. I can only hope I might get good at this one day, but seeing as I'm retired, I don't hold out a lot of hope for becoming too proficient at this. I don't have a life time to work in it.

    Thanks!

  13. #28
    Monty51 is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    48
    Quote Originally Posted by moke123 View Post
    Do you have any idea what this procedure is for?
    It appears to be setting a database property. Is there ever a value SetAppVersion passed to the function?

    I also think this db.Properties("AppVersion") should be db.Properties("Version") but i'm not positive.

    Is the timer interval set to 3 or 3000? 3000 is 3 seconds.

    Code:
    Public Function AppVersion(Optional SetAppVersion As Variant) As String
        On Error GoTo Err_AppVersion
    
    
        Dim db As Database
        Dim prpUserDefined As Property
    
    
        Set db = CurrentDb
        Set prpUserDefined = db.Properties("AppVersion")
        If IsMissing(SetAppVersion) Then    ' If no value sent the return value of property
            AppVersion = prpUserDefined.Value
        Else    ' Else set property to new value
            prpUserDefined.Value = SetAppVersion
            db.Properties.Refresh
            AppVersion = prpUserDefined.Value
        End If
        db.Close
        Set db = Nothing
    
    
    Exit_AppVersion:
        Exit Function
    Err_AppVersion:
        MsgBox Err.Description, vbCritical
        Resume Exit_AppVersion
    
    
    End Function

    The code is supposed to retrieve the software version, which appears to be stored in db.Properties. I'm not sure where that is or even if it's a default attribute of a db (I'm thinking it is, but haven't found documentation stating so).

    There is also a SetAppVersion that gets executed, but I didn't post it here to keep things simpler and (hopefully) clearer.

    I'm going to stop this thread. I have books coming which I hope will clear up a lot of stuff for me. I appreciate you taking a look and replying.

    Thanks

  14. #29
    Monty51 is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    48
    Quote Originally Posted by moke123 View Post
    If the above is correct then something like this may fix it.

    Code:
    Function CreateDBProperty(PropName As String, intType As Integer, PValue As String)
        Dim db As DAO.Database
        Dim P As Property
        Set db = DBEngine(0)(0)
        Set P = db.CreateProperty(PropName, intType, PValue)
        db.Properties.Append P
    End Function
    
    
    Sub AddMyProperty()
        Call CreateDBProperty("appVersion", dbText, "appVersion 2.0 " & Year(Now))
    End Sub
    There is a "SetAppVersion" routine, but I didn't post it because I didn't want to go TOO far down the rabbit hole.

    Thanks for looking. I'm going to stop this thread because it's obvious I need to read a whole lot more. I have books coming that will help...I hope.

  15. #30
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,569
    I would not get despondent.
    All it appears to be is a custom property that the developer created for an appversion.
    All you need to do is create that property in the new db as mentioned and set it to the required value.

    This only needs to be carried out once.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

Page 2 of 3 FirstFirst 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 08-04-2020, 06:58 AM
  2. Item not found in this collection .Fields(x) property
    By ironfelix717 in forum Programming
    Replies: 2
    Last Post: 05-19-2019, 10:53 PM
  3. Table suddenly says "Property Not Found"
    By templeowls in forum Access
    Replies: 1
    Last Post: 05-03-2019, 08:45 AM
  4. Replies: 1
    Last Post: 01-13-2019, 01:53 PM
  5. Replies: 7
    Last Post: 06-08-2012, 09:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums