Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / February 2008

Tip: Looking for answers? Try searching our database.

VBA - Access 97 to 2003

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bill B - 05 Feb 2008 14:37 GMT
Hi All.

I'm having a heck of a time here trying to sort some code out in an attempt
to convert a few VBA modules from 97 to 2003 and compile them.

At the moment I'm getting this error:

Error: Object variable or With block variable not set

from this code:

Function ref_intStartNewAccess() As Integer
On Error GoTo ref_intStartNewAccess_Err

   Dim intRet As Integer
   Dim mappAccess As Object

   ref_SetStatus 0, "Starting Access 2003 ..."
'Stop

   Set mappAccess = CreateObject("Access.Application.11")
   'mappAccess.Visible = false

   intRet = True

'Stop
ref_intStartNewAccess_Exit:
   ref_intStartNewAccess = intRet
   Exit Function

ref_intStartNewAccess_Err:
   intRet = False
   MsgBox "Error: " & Error$, vbExclamation, "ref_intStartNewAccess()"
   Resume ref_intStartNewAccess_Exit

End Function

Private Sub ref_SetStatus(ByVal pintType As Integer, ByVal pvarText As
Variant)

   Dim strMsg      As String
   Dim frm         As New Form
   Set frm = Forms!frmStatus

   If Not IsNull(pvarText) Then strMsg = pvarText

   Select Case pintType
       Case 0
           frm!lblMsg.Caption = strMsg
       Case 1
           frm!lblAppDB.Caption = strMsg
       Case 2
           frm!lblAppDesc.Caption = strMsg
       Case 3
           frm!lblLibDB.Caption = strMsg
       Case 4
           frm!lblPath.Caption = strMsg
    End Select

   frm.Repaint

End Sub

Any help sorting this out would be greatly appreciated.

Bill
Maurice - 05 Feb 2008 14:57 GMT
Shouldn't intRet be set to Boolean instead of Integer?
Set the Access object to (Access.application)
Signature

Maurice Ausum

> Hi All.
>
[quoted text clipped - 62 lines]
>
> Bill
Bill B - 05 Feb 2008 15:16 GMT
OK, that seems to have got me past that function and into the next. Now I
get the same error on it. Here's the code for that one

pstrDB does contact the value of the database I'm trying to open.

Function ref_intOpenDatabase(ByVal pstrDB As String) As Integer
On Error GoTo ref_intOpenDatabase_Err

   Dim intRet          As Boolean
   Dim strCurrDB       As String
   Const NO_DB_OPEN = 7952         '= Illegal function Call - no current
database

   ' special error handler to catch when no database is opened.
   On Error GoTo ref_intOpenDatabase_CurrentDB
   strCurrDB = mappAccess.CurrentDb.Name

   On Error GoTo ref_intOpenDatabase_Err

   If strCurrDB <> pstrDB Then
       mappAccess.CloseCurrentDatabase
   End If

ref_intOpenDatabase_OPEN:

   mappAccess.OpenCurrentDatabase mstrAccappPath & pstrDB, True

   intRet = True

ref_intOpenDatabase_Exit:
   ref_intOpenDatabase = intRet
   Exit Function

ref_intOpenDatabase_Err:

   intRet = False
   MsgBox "Error: " & Error$, vbExclamation, "ref_intOpenDatabase()"
   Resume ref_intOpenDatabase_Exit

ref_intOpenDatabase_CurrentDB:
   If Err = NO_DB_OPEN Then
       Resume ref_intOpenDatabase_OPEN
   Else
       intRet = False
       MsgBox "Error: " & Error$, vbExclamation, "ref_intOpenDatabase()"
       Resume ref_intOpenDatabase_Exit
   End If

End Function

> Shouldn't intRet be set to Boolean instead of Integer?
> Set the Access object to (Access.application)
[quoted text clipped - 66 lines]
>>
>> Bill
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.