Error: Undefined Function in Addin 
Author Message
 Error: Undefined Function in Addin

Hi,

  Can anyone shed some light on this error message in a 97 Add-in ?

  Error 3985: Undefined Function 'fGetLastUpdateStamp' in expression.

  The code is

  Set db = CodeDb

     'Get the last modified time
     db.Execute "UPDATE tblObjects SET LastUpdated = " _
                 & "fGetLastUpdateStamp([ObjectType],[ObjectName]) " _
                 & "Where dbID=" & Me.DBId, dbFailOnError

  'db.Execute "qryUpdateTimeStamp"

  The Querydef has the exact same SQL.  This is being run from Form_Open of
an Addin form, and runs fine if CodeDB=CurrentDB.

  The function is indeed in a public module and reads as follows.

  I hope I didn't miss anything. Any tips are highly appreciated.

   TA
   -- Dev

  '****** Code Start *******
   Function fGetLastUpdateStamp(intObjectType As Integer, _
         strObjectName As String) As Variant
  'Causing "not found" errors in a module?  Huh?
  '
  On Error GoTo ErrHandler
  Dim db As Database
  Dim datOut As Date

     Set db = CurrentDb

     Select Case intObjectType
        Case acTable:
           datOut = db.TableDefs(strObjectName).LastUpdated
        Case acQuery:
           datOut = db.QueryDefs(strObjectName).LastUpdated
        Case acForm:
           datOut =
db.Containers("Forms").Documents(strObjectName).LastUpdated
        Case acReport:
           datOut =
db.Containers("Reports").Documents(strObjectName).LastUpdated
        Case acMacro:
           datOut =
db.Containers("Scripts").Documents(strObjectName).LastUpdated
        Case acModule:
           datOut =
db.Containers("Modules").Documents(strObjectName).LastUpdated
     End Select
     fGetLastUpdateStamp = datOut
  ExitHere:
     Set db = Nothing
     Exit Function
  ErrHandler:
     fGetLastUpdateStamp = Null
     Resume ExitHere
 End Function
 '******* Code End *********



Sat, 01 Sep 2001 03:00:00 GMT  
 Error: Undefined Function in Addin
Hi All,

Thanks for all the responses.  I thought I'd save some keystrokes and make
one general post instead of replying to every post separately. :-)

I agree with Ken's analysis that the queries seem to be looking at the
CurrentDB during execution time, although why built in functions like Nz
won't work, is beyond me.

I ended up converting the couple of execute statements that were using
either custom or built in functions to good ol' DAO code and life's a tad
slower but otherwise grand. :-)

And also did a quick check with qualifying the function, but it didn't seem
to help.

As for the code replacement, this is it, with the original function
remaining the same.

Lastly, for those who wished to see the addin, well, please note that it's
still _very_ much in early beta at the moment and doesn't contain any docs.
etc, but here it is.

Thanks again.
 -- Dev

< http://home.att.net/~dashish2/downloads/wzbackup.zip >

'****** code start ********
Sub sLogLastUpdateStamp(lngID As Long)
'DAO replacement for an Action query since
'functions in SQL statement generate an
'error from Add-ins
'
'Read the time all objects in CurrentDB were last updated
'
On Error GoTo ErrHandler
Dim strSQL As String
Dim dbCurr As Database
Dim rsCurr As Recordset

   Set dbCurr = CodeDb
   'Which objects we need to look up?
   strSQL = "Select LastUpdated, ObjectType, ObjectName From " _
                     & "tblObjects Where DBID = " & lngID
   Set rsCurr = dbCurr.OpenRecordset(strSQL, dbOpenDynaset)
   With rsCurr
      If .RecordCount > 0 Then
         Do While Not .EOF
            .Edit
               'Get the LastUpdated stamp from the container
               !LastUpdated = fGetLastUpdateStamp(!ObjectType, _

!ObjectName)
            .Update
            .MoveNext
         Loop
      End If
   End With

ExitHere:
   Set rsCurr = Nothing
   Set dbCurr = Nothing
   Exit Sub
ErrHandler:
   MsgBox Err.Description & " (" & Err.Number & ")", vbCritical,
"sLogLastUpdateStamp"
   Resume ExitHere
End Sub
'********** Code End ***********

    -- Dev



Mon, 03 Sep 2001 03:00:00 GMT  
 Error: Undefined Function in Addin
Dev: you can avoid the DAO code by just running your query, though without
the options available with db.execute:

DoCmd.setwarnings false
DoCmd.OpenQuery "qryUpdateTimeStamp"
DoCmd.setwarnings true

Why this works and not the db.execute, who knows.

Hope this helps,
GR

Quote:

>Hi All,

>Thanks for all the responses.  I thought I'd save some keystrokes and make
>one general post instead of replying to every post separately. :-)

>I agree with Ken's analysis that the queries seem to be looking at the
>CurrentDB during execution time, although why built in functions like Nz
>won't work, is beyond me.

>I ended up converting the couple of execute statements that were using
>either custom or built in functions to good ol' DAO code and life's a tad
>slower but otherwise grand. :-)

>And also did a quick check with qualifying the function, but it didn't seem
>to help.

>As for the code replacement, this is it, with the original function
>remaining the same.

>Lastly, for those who wished to see the addin, well, please note that it's
>still _very_ much in early beta at the moment and doesn't contain any docs.
>etc, but here it is.

>Thanks again.
> -- Dev

>< http://home.att.net/~dashish2/downloads/wzbackup.zip >

>'****** code start ********
>Sub sLogLastUpdateStamp(lngID As Long)
>'DAO replacement for an Action query since
>'functions in SQL statement generate an
>'error from Add-ins
>'
>'Read the time all objects in CurrentDB were last updated
>'
>On Error GoTo ErrHandler
>Dim strSQL As String
>Dim dbCurr As Database
>Dim rsCurr As Recordset

>   Set dbCurr = CodeDb
>   'Which objects we need to look up?
>   strSQL = "Select LastUpdated, ObjectType, ObjectName From " _
>                     & "tblObjects Where DBID = " & lngID
>   Set rsCurr = dbCurr.OpenRecordset(strSQL, dbOpenDynaset)
>   With rsCurr
>      If .RecordCount > 0 Then
>         Do While Not .EOF
>            .Edit
>               'Get the LastUpdated stamp from the container
>               !LastUpdated = fGetLastUpdateStamp(!ObjectType, _

>!ObjectName)
>            .Update
>            .MoveNext
>         Loop
>      End If
>   End With

>ExitHere:
>   Set rsCurr = Nothing
>   Set dbCurr = Nothing
>   Exit Sub
>ErrHandler:
>   MsgBox Err.Description & " (" & Err.Number & ")", vbCritical,
>"sLogLastUpdateStamp"
>   Resume ExitHere
>End Sub
>'********** Code End ***********

>    -- Dev



Tue, 04 Sep 2001 03:00:00 GMT  
 Error: Undefined Function in Addin
I don't know why the timer event makes a difference, but I knew the function
was working before I started calling it from Form_Open so I figured the open
event of the startup form was the problem.  By the way this code was not in an
addin.  I forgot to mention that.  It is Acc97, base release.
Quote:

> Ed,

> What has me fascinated is why should the timer event make a difference? Any
> idea? Dev, have you tried this? Did it help?

> Calum


> >Dev,

> >I have no idea what causes it but I ran into the same thing calling a
> function
> >with this code in Form_Open of my startup form:

> >  Set dbs = OpenDatabase(strFileName)
> >  blnOpened = True
> >  strSQL = "SELECT DISTINCTROW Description " & _
> >   "FROM MSysReplicas " & _
> >   "WHERE StringFromGUID(ReplicaId)=""" & Mid$(dbs.ReplicaId, 7, 38) &
> """;"
> >  Set qdf = dbs.CreateQueryDef("", strSQL)
> >  Set rst = qdf.OpenRecordset(dbOpenSnapshot)

> >I was getting error 3085: "Undefined function 'StringFromGUID' in
> expression"

> >I just put the function call in an On Timer event procedure with a Timer
> >Interval of 100 and it went away.  When all else fails, I look for a
> kludge.

> >Ed



Tue, 04 Sep 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. DEV ASHISH - Bugs: Undefined Function in Expression (Error 3985)

2. Convert Julian to Gregorian Returns Undefined Function Error

3. MDE fixes undefined function error in export wizard?

4. Run Time error 3085 - Undefined Function

5. SQL Error 3085 - Function undefined

6. function undefined error - help needed

7. Error-- Undefined Function 'LEFT' in express

8. Error 3085 Undefined Function

9. Undefined Function Access/Excel

10. Undefined function 'replace' in expression

11. Undefined Function

12. Undefined function in expression (again...)

 

 
Powered by phpBB® Forum Software