I have a subroutine that compiles and runs successfully when run manually. I'm trying to set up Autpen so that it is run on open, but it doesn't seem to be working. It is definitely kicking off the Autpen, as the MsgBox displays properly, but it does not seem to run my getFunctionDetails subroutine. My code is below:
Code:
Private Sub Auto_Open()
MsgBox "HELLO WORLD!"
Call getFunctionDetails
End Sub
' Subroutine getFunctionDetails
'
' Populate function and parameter descriptions based on FUNC_DTL table
'
Sub getFunctionDetails()
On Error GoTo dbferror
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim vArgDescr() As Variant
Dim vArgCounter As Integer
vArgCounter = 1
Set db = DBEngine.OpenDatabase("C:\INSERT_DIRECTORY_NAME_HERE\Database\INSERT_DB_NAME_HERE.accdb", dbReadOnly)
Set rs = db.OpenRecordset("SELECT * FROM FUNC_DTL_V", dbReadOnly)
rs.MoveFirst
While Not rs.EOF
If rs!PRMTR_ID = 1 Then
ReDim vArgDescr(1 To rs!PRMTR_CT) As Variant
End If
If rs!PRMTR_ID = 0 Then
Application.MacroOptions Macro:=rs!FUNC_NM, Description:=rs!CODE_FORMAT, Category:=rs!UD_CAT, ArgumentDescriptions:=vArgDescr
vArgCounter = 0
Else
vArgDescr(vArgCounter) = rs!CODE_FORMAT
End If
vArgCounter = vArgCounter + 1
rs.MoveNext
Wend
rs.Close
db.Close
Exit Sub
dbferror:
getdbfver = "DBF: error " & Err.Description
End Sub