Thanks for your input. Had I written this application, I can only hope I would have put some debugging options in.
Thanks for your input. Had I written this application, I can only hope I would have put some debugging options in.
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
Sigh...these replies are not posting where I thought they would. Sorry for the confusion.
You can make indenting in your code stick by use code tags, the # icon in the reply area.
To preserve indenting, highlight you code and click the # button
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
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.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
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.
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
@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
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.
this line is probably the errorI've narrowed my first error down to a routine that's supposed to set an "AppVersion" variable when this form opens.
It's not finding that property because it does not exist in the new database.Code:Set prpUserDefined = db.Properties("AppVersion")
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
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
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!
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
There is a "SetAppVersion" routine, but I didn't post it because I didn't want to go TOO far down the rabbit hole.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
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.
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