Newsgroup: it.comp.lang.visual-basic
Titolo: Error 424 object required

hi their,
I have written a small program to update database and now I have
created a module added all that code in there.
I have added the follwing line to execute the module code:
ModUpdateDB.updateDB
but when it executes it throws up error 424 object required, any reason
why would it do that?
Public Function updateDB()
Dim dbversion As String
Dim dbFileName As String
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Dim sqlstr As String
Dim error_code As String
Dim SysData As SystemData
On Error GoTo GetExclusiveAccess_error
dbFileName = cdbConnection.FileName 'Insert database file name and path
into dbfilename
   'Try to create a connection to the selected database
   Set cnnSQARED = New ADODB.Connection
   'Get Exclusive access to the database and open the database to
update tables
   cnnSQARED.Provider = "Microsoft.Jet.OLEDB.4.0"
   ' Firstly, we need to make sure that we have exclusive access to the
database, as
   ' we are going to access it, update the database database fields,
then update the data,
   ' so we can't have anyone else modifying it in the meantime.
   ' Get exclusive access to the database
   cnnSQARED.Mode = adModeShareExclusive
   cnnSQARED.Open dbFileName
   Set SysData = New SystemData
   Set SysData.dbconnection = cnnSQARED
   strsql = "SELECT * FROM systemdata WHERE
(((systemdata.mainsection)='DataBase')) "
   dbversion = SysData.GetValue("DataBase", "Version", "")
   If dbversion = "" Then
      SysData.SaveValue "DataBase", "Version", 0
       dbversion = SysData.GetValue("DataBase", "Version", "")
      MsgBox "Database version is " & dbversion
      On Error GoTo GetExclusiveAccess_error
      dbFileName = cdlfile.FileName 'Insert database file name and path
into dbfilename
      MsgBox dbFileName
      If dbFileName = "" Then
         MsgBox "No database File Selected, Click on Browse button to
select a database file."
         txtdbfile.SetFocus
         txtdbfile.BackColor = vbRed
       Exit Function
      End If
      'Create a command to change field length to 255
      Set comalter = New ADODB.Command
      'Change column error_message's width in CandidateErrors table
width to 255
      strsql = ("ALTER TABLE CandidateErrors ALTER COLUMN error_message
Text(255)")
      'Execute Command to change field length to 255
      With comalter
         .ActiveConnection = cnnSQARED
          .CommandText = strsql
          .CommandType = adCmdText
          .Execute
      End With
      'Change column error_message's width in EntryErrors table width
to 255
      strsql = ("ALTER TABLE EntryErrors ALTER COLUMN error_message
Text(255)")
         comalter.CommandText = strsql
         comalter.Execute
      SysData.SaveValue "DataBase", "Version", 1
      'Close connection
      cnnSQARED.Close
      'clear connection string
      Set cnnSQARED = Nothing
   End If
Exit Function
GetExclusiveAccess_error:
        If Err.Number = -
2147467259
 Then
           'database being used by another user
           MsgBox "To Update database you need exclusive access to the
database." & vbCrLf & _
                        "Another user or program is currently
accessing the database." & vbCrLf & vbCrLf & _
                        "Please try later when you have exclusive
access.", vbOKOnly + vbInformation, "Database access error"
        End If
End Function
Regards
Saqi

