Help with DELETE Query

K

kealaz

I want to delete from tblBUY those parts that I just cut a purchase order for.

tblBUY does not have P_O_NO because it is before the purchase order is cut.
Below is my code for the command button that Issues the Purchase Order. In
the code...

strCriteria has the purchase order number

I want to build a query that filters tblBUYHIST on strCriteria and then take
ALL of the part numbers [PART_NO] on the resulting records and delete all
records with matching part numbers [PART_NO] on tblBUY.

I only want to delete records from tblBUY, not tblBUYHIST.


*************************************************

Private Sub ISSUE_PO_Click()
On Error GoTo Err_ISSUE_PO_Click

Const conREPORTNAME = "rptPO"
Dim strCriteria As String

strCriteria = " P_O_NO = """ & Forms("frmPO_ISSUE").P_O_NO & """"

' close form
DoCmd.Close acForm, "frmPO_ISSUE"

' open report in print preview
DoCmd.OpenReport conREPORTNAME, _
View:=acViewPreview, _
WhereCondition:=strCriteria

Exit_ISSUE_PO_Click:
Exit Sub

Err_ISSUE_PO_Click:
MsgBox Err.Description
Resume Exit_ISSUE_PO_Click

End Sub

*************************************************


Here's what I'm trying.



I have created a SELECT Query [qryDeleteBUY_a]

Field: P_O_NO
Table: tblBUYHIST
Criteria: [Enter PO No:] I'm want to change this so that it gets the info
from strCriteria from my form [frmPO_ISSUE].

Field: PART_NO
Table: tblBUYHIST


This isolates the P.O. I enter. I would like it to eventually result with
the P.O. I am calling with strCriteria from code above.



I'm also creating a DELETE Query [qryDeleteBUY_b]

Field: tblBUY.*
Table: tblBUY
Delete: From or Where ???
Criteria: ???


Field: PART_NO
Table: qryDeleteBUY_a
Delete: From or where ???
Criteria: ???


*************************************************


I am not sure what to use as the Criteria to accomplish what I'm trying to
do. I'm sure there's an easier way. Any help would be greatly appreciated!!!
 

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