how do i query local tables?

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
 
K

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top