how do i query local tables?

  • Thread starter Thread starter Kim
  • Start date Start date
K

Kim

from within access vba code - how do I query local tables and get a
recordset?

I can connect to another db and query - but can someone point me in the
correct direction for creating a recordset on a local access table?

thanks in advance, kim
 
I figured it out..

strSQL = "Select orderID from orders where customerID=" & customerID
Dim db As DAO.Database
Dim cn As Adodb.Connection
Set db = CurrentDb
Set cn = CurrentProject.Connection

Dim objRs As Adodb.Recordset
Set objRs = cn.Execute(strSQL)

If Not objRs.EOF Then
strSQL = "Delete from participant where orderID=" &
objRs("OrderID").Value
exeSQL (strSQL)
strSQL = "Delete from orderDetail where orderID=" &
objRs("OrderID").Value
exeSQL (strSQL)
strSQL = "Delete from orders where orderID=" &
objRs("OrderID").Value
exeSQL (strSQL)
strSQL = "Delete from customer where customerID=" & customerID
exeSQL (strSQL)
MsgBox ("Customer and supporting data has been deleted.")
End If
 
Back
Top