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 / Modules / DAO / VBA / November 2006

Tip: Looking for answers? Try searching our database.

Object Required Error

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kontra - 13 Nov 2006 21:35 GMT
I am not sure why I get that error I have commented the part of code that
gives an error:

Set CONNTDC = New ADODB.Connection
   CONNTDC.Open connstring
Set rsItem = New ADODB.Recordset
rsItem.ActiveConnection = CONNTDC
rsItem.Open "SELECT IMFGR, ICOLOR, IPATT, ICCTR, IPOL1, IPOL2, IPOL3 FROM
QS36F.ITEM"

DoCmd.DeleteObject acTable, "tblItem"
CurrentProject.Connection.Execute "CREATE TABLE tblItem(MFGR CHAR(3), COLOR
CHAR(4), PATTERN CHAR(9), COSTCENTER CHAR(3), IPOL1 CHAR(3), IPOL2 CHAR(3),
IPOL3 CHAR(3))"

While Not rsItem.EOF
''''''''''''''''''''''''''''''''''If rsItem.Fields(4).Value Is Null Then '
this is where I get an error.
   FPOL1 = "-"
   Else: FPOL1 = rsItem.Fields(4).Value
       If rsItem.Fields(5).Value Is Null Then
           FPOL2 = "-"
           Else: FPOL2 = rsItem.Fields(5).Value
               If rsItem.Fields(6).Value Is Null Then
                   FPOL3 = "-"
                   Else: FPOL3 = rsItem.Fields(6).Value
               End If
       End If
End If

DoCmd.RunSQL "INSERT into tblItem values('" & rsItem.Fields(0).Value & "',"
& QS(rsItem.Fields(1).Value) & "," & QS(rsItem.Fields(2).Value) & ",'" &
rsItem.Fields(3).Value & "','" & FPOL1 & "','" & FPOL2 & "','" & FPOL3 & "')"

rsItem.MoveNext
Wend
rsItem.Close
CONNTDC.Close
Signature

If at first you don''''''''t succeed, destroy all evidence that you tried.

ruralguy - 13 Nov 2006 22:00 GMT
Is Null is used in SQL.  In VBA you need to use the IsNull() function.

For example:  If IsNull(rsItem.Fields(4)) Then

For the record, the .Value property is the default property in VBA and need
not be specified.

>I am not sure why I get that error I have commented the part of code that
>gives an error:
[quoted text clipped - 34 lines]
>rsItem.Close
>CONNTDC.Close

Signature

HTH - RuralGuy (RG for short) acXP WinXP Pro
Please post back to this forum so all may benefit.

 
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.