By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,477 Members | 1,627 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,477 IT Pros & Developers. It's quick & easy.

run time error 424 object required

P: n/a
Debug stops at the 3rd line of this code (Set rs =
db.openrecordset("IMPORT") why?
Private Sub Command118_Click()
Dim rs As DAO.Recordset
Set rs = db.openrecordset("IMPORT")
With rs
.MoveFirst
prev = !NOM_ACCOUNT
.MoveNext
Do
Select Case prev
Case "1700"
If !NOM_ACCOUNT <> "2300" Then
MsgBox "There has been an error in row # " & !NOM_ID & vbCrLf &
"Validation failed", , "Error"
Exit Sub 'or Exit Function
End If
Case "2300"
If !NOM_ACCOUNT <> "3200" Then
MsgBox "There has been an error in row # " & !NOM_ID & vbCrLf &
"Validation failed", , "Error"
Exit Sub 'or Exit Function
End If
Case "3200"
If !NOM_ACCOUNT <> "1700" Then
MsgBox "There has been an error in row # " & !NOM_ID & vbCrLf &
"Validation failed", , "Error"
Exit Sub 'or Exit Function
End If
End Select
prev = !NOM_ACCOUNT
.MoveNext
Loop Until .EOF
.Close
End With
Set rs = Nothing
Set db = Nothing
End Sub

--
Thanks,
Chris
cc****@NOSPAMeclipse.co.uk
Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
HJ
You should declare db as well.

Private Sub Command118_Click()

Dim db As DAO.Database
Dim rs As DAO.Recordset
Set rs = db.openrecordset("IMPORT")
....

HJ
"Lapchien" <cc****@NOSPAMeclipse.co.uk> wrote in message
news:10***************@ananke.eclipse.net.uk...
Debug stops at the 3rd line of this code (Set rs =
db.openrecordset("IMPORT") why?
Private Sub Command118_Click()
Dim rs As DAO.Recordset
Set rs = db.openrecordset("IMPORT")
With rs
.MoveFirst
prev = !NOM_ACCOUNT
.MoveNext
Do
Select Case prev
Case "1700"
If !NOM_ACCOUNT <> "2300" Then
MsgBox "There has been an error in row # " & !NOM_ID & vbCrLf &
"Validation failed", , "Error"
Exit Sub 'or Exit Function
End If
Case "2300"
If !NOM_ACCOUNT <> "3200" Then
MsgBox "There has been an error in row # " & !NOM_ID & vbCrLf &
"Validation failed", , "Error"
Exit Sub 'or Exit Function
End If
Case "3200"
If !NOM_ACCOUNT <> "1700" Then
MsgBox "There has been an error in row # " & !NOM_ID & vbCrLf &
"Validation failed", , "Error"
Exit Sub 'or Exit Function
End If
End Select
prev = !NOM_ACCOUNT
.MoveNext
Loop Until .EOF
.Close
End With
Set rs = Nothing
Set db = Nothing
End Sub

--
Thanks,
Chris
cc****@NOSPAMeclipse.co.uk

Nov 12 '05 #2

P: n/a
HJ wrote:
You should declare db as well.

Private Sub Command118_Click()

Dim db As DAO.Database
Dim rs As DAO.Recordset
Set rs = db.openrecordset("IMPORT")
I think you should set it as well;

Set db = Currentdb()


HJ
"Lapchien" <cc****@NOSPAMeclipse.co.uk> wrote in message
news:10***************@ananke.eclipse.net.uk...
Debug stops at the 3rd line of this code (Set rs =
db.openrecordset("IMPORT") why?
Private Sub Command118_Click()
Dim rs As DAO.Recordset
Set rs = db.openrecordset("IMPORT")
With rs
.MoveFirst
prev = !NOM_ACCOUNT
.MoveNext
Do
Select Case prev
Case "1700"
If !NOM_ACCOUNT <> "2300" Then
MsgBox "There has been an error in row # " & !NOM_ID &
vbCrLf & "Validation failed", , "Error"
Exit Sub 'or Exit Function
End If
Case "2300"
If !NOM_ACCOUNT <> "3200" Then
MsgBox "There has been an error in row # " & !NOM_ID &
vbCrLf & "Validation failed", , "Error"
Exit Sub 'or Exit Function
End If
Case "3200"
If !NOM_ACCOUNT <> "1700" Then
MsgBox "There has been an error in row # " & !NOM_ID &
vbCrLf & "Validation failed", , "Error"
Exit Sub 'or Exit Function
End If
End Select
prev = !NOM_ACCOUNT
.MoveNext
Loop Until .EOF
.Close
End With
Set rs = Nothing
Set db = Nothing
End Sub

--
Thanks,
Chris
cc****@NOSPAMeclipse.co.uk


Nov 12 '05 #3

P: n/a
HJ
Yes, you are right. Forgot to mention that.

HJ

"Deano" <ma************@hotmail.com> wrote in message
news:Dz*******************@wards.force9.net...
HJ wrote:
You should declare db as well.

Private Sub Command118_Click()

Dim db As DAO.Database
Dim rs As DAO.Recordset
Set rs = db.openrecordset("IMPORT")


I think you should set it as well;

Set db = Currentdb()


HJ
"Lapchien" <cc****@NOSPAMeclipse.co.uk> wrote in message
news:10***************@ananke.eclipse.net.uk...
Debug stops at the 3rd line of this code (Set rs =
db.openrecordset("IMPORT") why?
Private Sub Command118_Click()
Dim rs As DAO.Recordset
Set rs = db.openrecordset("IMPORT")
With rs
.MoveFirst
prev = !NOM_ACCOUNT
.MoveNext
Do
Select Case prev
Case "1700"
If !NOM_ACCOUNT <> "2300" Then
MsgBox "There has been an error in row # " & !NOM_ID &
vbCrLf & "Validation failed", , "Error"
Exit Sub 'or Exit Function
End If
Case "2300"
If !NOM_ACCOUNT <> "3200" Then
MsgBox "There has been an error in row # " & !NOM_ID &
vbCrLf & "Validation failed", , "Error"
Exit Sub 'or Exit Function
End If
Case "3200"
If !NOM_ACCOUNT <> "1700" Then
MsgBox "There has been an error in row # " & !NOM_ID &
vbCrLf & "Validation failed", , "Error"
Exit Sub 'or Exit Function
End If
End Select
prev = !NOM_ACCOUNT
.MoveNext
Loop Until .EOF
.Close
End With
Set rs = Nothing
Set db = Nothing
End Sub

--
Thanks,
Chris
cc****@NOSPAMeclipse.co.uk


Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.