I'm having a bit of a headache with trying to run a delete query using the results of a select query, in VB code. My first query runs OK, but when I try running the second query, I keep getting a message, "Object required."
I've enclosed my code that is causing the problem..... if y'all could take a look at it and tell me the erors of my ways, I would be very happy.
VB Code:
Dim rsMstrPN As New ADODB.Recordset Dim rsDuplicates As New ADODB.Recordset Dim strSQL As String Dim strErrMsg As String Dim lngRecCount As Long Dim lngTotalRec As Long Dim strPartId As String '========================================================================== ' Variable Initialization Section '========================================================================== DeletePNdata = False '========================================================================== ' Code Section '========================================================================== strSQL = "" strSQL = strSQL & "select DuplicatePartsBad.PNID from DuplicatePartsBad " strSQL = strSQL & "Order by DuplicatePartsBad.PNID" rsDuplicates.Open strSQL, conJetMasterDb, adOpenStatic, adLockReadOnly, adCmdText If Not (rsDuplicates.EOF = True And rsDuplicates.BOF = True) Then rsDuplicates.MoveFirst Do While Not rsDuplicates.EOF strPartId = rsDuplicates!PNID strSQL = "" strSQL = strSQL & "Delete * from MasterPN where MasterPN.PNId = " & strPartId & "; " Debug.Print strSQL rsMasterPN.Open strSQL, conJetMasterDb, adOpenStatic, adLockOptimistic, adCmdText Loop End If rsMstrPN.Close rsDestination.Close
Thaks to all of you who help out this myopic programmer!!




Reply With Quote