The code below deletes the departments from the MasterTbl in another database,
based on the departments selected from the list. I'd like to change that, so
it deletes the records from a query NOT the selected items.
Dim strSQL As String
Dim varItem As Variant
Dim frm As Form, ctl As Control
Set frm = Forms!frmSetup
Set ctl = frm!lstMyDepartments
Set db = OpenDatabase("F:\Vendor Matrix\Data\Source\Maintenance Database -
F09\MENS Fall FY09 Vendor Maintenance.mdb")
Set rstDate = db.OpenRecordset("MasterTbl")
answer = MsgBox("Did you already export your changes?", vbYesNo, "WAIT!")
If answer = vbNo Then
DoCmd.SetWarnings False
For Each varItem In ctl.ItemsSelected
strSQL = "DELETE * FROM [MasterTbl] IN 'F:\Vendor Matrix\Data\Source\
Maintenance Database - F09\MENS Fall FY09 Vendor Maintenance.mdb'" & _
" WHERE [Department #] = " & ctl.ItemData(varItem) & ""
DoCmd.RunSQL strSQL
KARL said:
Post the rest of the quey SQL.
This is in conjunction with my previous thread. I'll try and simplify my
request.
[quoted text clipped - 4 lines]