Run Time error '424' Object required. (1 Viewer)

brewpedals

Registered User.
Local time
Today, 06:14
Joined
Oct 16, 2002
Messages
32
It's Friday and I'm not seeing straight! Can you spot the reason I'm getting this error? I get the error on bold red line in the code.

Thanks.

Here's my code:
Code:
Public Function GetCircuitExtInspDatesFromLines()
'Dim x As Integer 'Changed Circuit External Inspection date count.
Dim db As Database
Dim rsLineDates As Recordset
Dim rsCircDates As Recordset
Dim sqlLineDates As String 'List of Line Exteral Inspection Dates.
Dim sqlCircDates As String ' List of Circuits and their External Inspection dates with a null Last External Inspection date.
Dim strLineLastExtDate ' As Date
Dim strLineNextExtDate ' As Date
Dim strCircuit As String
Dim strQuote As String
'Dim varResult As Variant
'Dim varProgress As Variant


strQuote = Chr$(34)

DoCmd.Hourglass True

Set db = CurrentDb

sqlCircDates = "SELECT tbl_IntExt.ASSETID, tbl_IntExt.LastExtInsp, tbl_IntExt.NextExtInsp, tbl_IntExt.LineKey " & _
                "FROM tbl_IntExt " & _
                "WHERE (((tbl_IntExt.LastExtInsp) Is Null) And ((tbl_IntExt.Circuit) = -1)) " & _
                "ORDER BY tbl_IntExt.ASSETID;"
                
Set rsCircDates = db.OpenRecordset(sqlCircDates, dbOpenDynaset)
'x = 0
'varProgress = 0
'Me.ActiveXCtl1.Visible = True
'Me.ActiveXCtl1.Max = rs.RecordCount


Do Until rsCircDates.EOF
    strCircuit = rsCircDates!LineKey 'Get the LineKey for the Circuit.
             
    sqlLineDates = "SELECT tbl_IntExt.CircuitKey, tbl_IntExt.LastExtInsp, tbl_IntExt.NextExtInsp " & _
                "FROM tbl_IntExt " & _
                "WHERE (((tbl_IntExt.Circuit) = 0) AND (tbl_IntExt.CircuitKey)= " & strCircuit & ") " & _
                "ORDER BY tbl_IntExt.LastExtInsp, tbl_IntExt.NextExtInsp;"
    
    Set rsLineDates = db.OpenRecordset(sqlLineDates) ', dbOpenDynaset)
    
    'Get the last external inspection date.
    rsLineDates.MoveFirst
    [B][COLOR="Red"]If rsLineDates![LastExtInsp] Is Null Then
        strLineLastExtDate = ""[/COLOR][/B]
    Else
        strLineLastExtDate = rsLineDates![LastExtInsp]
    End If
    
    'Get the next external inspection date.
    If rsLineDates![NextExtInsp] Is Null Then
        strLineNextExtDate = ""
    Else
        strLineNextExtDate = rsLineDates![NextExtInsp]
    End If
    
    'x = x + 1 ' Advance the record count.
    
    'Put the lines External Inspection dates in the Circuit record
    With rsCircDates
    .Edit
    !LastExtInsp = strLineLastExtDate
    !NextExtInsp = strLineNextExtDate
    .Update
    End With
      
    rsCircDates.MoveNext
    'varProgress = varProgress + 1
    'Me.ActiveXCtl1.Value = varProgress
    'Me.Text1.Value = varProgress & " lines out of " & Me.ActiveXCtl1.Max & " have been checked. " & x & " duplicates are marked."
    'Me.Repaint
Loop

'Me.Text1.Value = "Finished! " & x & " Duplicates were found and marked out of " & Me.ActiveXCtl1.Max & "."
'Me.Text1.Requery


Set db = Nothing
Set rsCircDates = Nothing
Set rsLineDates = Nothing
'Me.ActiveXCtl1.Visible = False
DoCmd.Hourglass False

MsgBox "Finished replacing Circuit External Inspection Dates.", , "Finished"
    
End Function
 

ajetrumpet

Banned
Local time
Today, 00:14
Joined
Jun 22, 2007
Messages
5,638
change this:
Code:
    [B][COLOR="Red"]If rsLineDates![LastExtInsp] Is Null Then
        strLineLastExtDate = ""[/COLOR][/B]
To this:
Code:
If [color=red]isnull[/color](rsLineDates![LastExtInsp]) Then
The code is reading the Is Null portion of your statement as an expected "variable assigning" command.
 

brewpedals

Registered User.
Local time
Today, 06:14
Joined
Oct 16, 2002
Messages
32
Thanks for your help ajetrumpet! That was it.

Have a great weekend!
 

Users who are viewing this thread

Top Bottom