Hello,
I have a problem using an autoexec macro within access.
With help of my macro, I display the path and filename of my database on top of the access application windows. So far so good, but I want even to display some datas from the database e.g. our projectname wich is a date from an cell.
When I open access, the path is displayed, but not the projectname. When I start the macro manually once again, even the project name is displayed, so it seems to be, that when autoexec is executed access is not ready for reading out datas from tables, so that it seems to be, that I need a delay time or an event trigger.
I hope somebody can help me.
Here is my code
I have a problem using an autoexec macro within access.
With help of my macro, I display the path and filename of my database on top of the access application windows. So far so good, but I want even to display some datas from the database e.g. our projectname wich is a date from an cell.
When I open access, the path is displayed, but not the projectname. When I start the macro manually once again, even the project name is displayed, so it seems to be, that when autoexec is executed access is not ready for reading out datas from tables, so that it seems to be, that I need a delay time or an event trigger.
I hope somebody can help me.
Here is my code
Code:
' -----------------------------------------------
' Filename und Pfad im Access-Fenster anzeigen
' -----------------------------------------------
Function SetApplicationTitle(ByVal MyTitle As String)
If SetStartupProperty("AppTitle", dbText, MyTitle) Then
Application.RefreshTitleBar
Else
MsgBox "ERROR: Could not set Application Title"
End If
End Function
Function SetStartupProperty(prpName As String, _
prpType As Variant, prpValue As Variant) As Integer
Dim DB As DAO.Database, PRP As DAO.Property, WS As Workspace
Const ERROR_PROPNOTFOUND = 3270
Set DB = CurrentDb()
' Set the startup property value.
On Error GoTo Err_SetStartupProperty
DB.Properties(prpName) = prpValue
SetStartupProperty = True
Bye_SetStartupProperty:
Exit Function
Err_SetStartupProperty:
Select Case Err
' If the property does not exist, create it and try again.
Case ERROR_PROPNOTFOUND
Set PRP = DB.CreateProperty(prpName, prpType, prpValue)
DB.Properties.Append PRP
Resume
Case Else
SetStartupProperty = False
Resume Bye_SetStartupProperty
End Select
End Function
Function CurrentMDB() As String
Dim i As Integer, FullPath As String
FullPath = CurrentDb.Name
' Search backward in string for back slash character.
For i = Len(FullPath) To 1 Step -1
' Return all characters to the right of the back slash.
If Mid(FullPath, i, 1) = "\" Then
CurrentMDB = Mid(FullPath, i + 1)
Exit Function
End If
Next i
End Function
Function UpdateAppTitle()
Dim Version As String
Dim Projektname As String
Version = DLookup("MMC_Basisversion", "T-MMC Daten")
Projektname = DLookup("Version", "T-MMC Daten")
SetApplicationTitle (CurrentProject.Path & " -- MMC 4000 -- Version: " & Version & " -- " & Projektname)
!!!!!!!!!!!!!!!!!! Above only the Path is displayed, not Version and Projektname !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
End Function
Comment