Here is the code. The error appears at the Do Until statement. Any ideas, I am so frustrated. Thanks
Option Compare Database
Private Sub Command0_Click()
Dim SQLa, SQLb, SQLc, SQLd As String
Dim conn As ADODB.Connection: Dim rs As ADODB.Recordset: Set conn = New ADODB.Connection
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= c:\temp\john.mdb" & ";" & _
"Persist Security Info=False": conn.Open
With rs
Do Until .EOF
SQLa = "SELECT top 1 Plant, Material, [Material Description], RDC from FESA"
Set rs = conn.Execute(SQLa, , adCmdText)
P = rs.Fields("Plant").Value: M = rs.Fields("Material").Value: MD = rs.Fields("Material Description").Value
R = rs.Fields("RDC").Value
SQLb = "SELECT sum(Quantity) as Quan from FESA where Material='" & M & "' and RDC = " & R
Set rs = conn.Execute(SQLb, , adCmdText)
Q = rs.Fields("Quan").Value
SQLc = "Insert Into Results (Plant, Material, [Material Description], Quantity, RDC) values (" & P & ", '" & M & "', '" & MD & "'," & Q & ", " & R & ");"
Set rs = conn.Execute(SQLc, , adCmdText)
SQLd = "Delete * from FESA where Material='" & M & "' and RDC = " & R
Set rs = conn.Execute(SQLd, , adCmdText)
Loop
If .EOF = True Then rs.Close: conn.Close: Set rs = Nothing: Set conn = Nothing
OK = MsgBox("Done.", vbOKOnly + vbInformation, "Production Management Tool"): Exit Sub
End With
End Sub
Option Compare Database
Private Sub Command0_Click()
Dim SQLa, SQLb, SQLc, SQLd As String
Dim conn As ADODB.Connection: Dim rs As ADODB.Recordset: Set conn = New ADODB.Connection
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= c:\temp\john.mdb" & ";" & _
"Persist Security Info=False": conn.Open
With rs
Do Until .EOF
SQLa = "SELECT top 1 Plant, Material, [Material Description], RDC from FESA"
Set rs = conn.Execute(SQLa, , adCmdText)
P = rs.Fields("Plant").Value: M = rs.Fields("Material").Value: MD = rs.Fields("Material Description").Value
R = rs.Fields("RDC").Value
SQLb = "SELECT sum(Quantity) as Quan from FESA where Material='" & M & "' and RDC = " & R
Set rs = conn.Execute(SQLb, , adCmdText)
Q = rs.Fields("Quan").Value
SQLc = "Insert Into Results (Plant, Material, [Material Description], Quantity, RDC) values (" & P & ", '" & M & "', '" & MD & "'," & Q & ", " & R & ");"
Set rs = conn.Execute(SQLc, , adCmdText)
SQLd = "Delete * from FESA where Material='" & M & "' and RDC = " & R
Set rs = conn.Execute(SQLd, , adCmdText)
Loop
If .EOF = True Then rs.Close: conn.Close: Set rs = Nothing: Set conn = Nothing
OK = MsgBox("Done.", vbOKOnly + vbInformation, "Production Management Tool"): Exit Sub
End With
End Sub