K
kealaz
I have a command button that I am using on a form [frmPO_ISSUE]. This
command button is currently closing the form and opening a report. The
report is based on a query and the query is run using the strCriteria (which
comes from a text box on the form). The code is below. All of this is
working so far.
*********************************************
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
***********************************************
I want to add the following code to the above command button. I have tried,
and it's not working. I have verified that the SQL query works. I just
don't know how to integrate it into the code I already have. The part that
it's not liking is "WhereCondition:=strCriteria" It works for opening
report/query to view the purchase order. I thought that I could use the same
method for another query. The SQL statement below is a delete query.
qryDeleteBUY_a is a select query.
******* code I want to add to the above ********
'save record
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
'run query
DoCmd.RunSQL "DELETE tblBUY.PART_NO FROM tblBUY WHERE PART_NO IN (SELECT
PART_NO FROM qryDeleteBUY_a);"
WhereCondition:=strCriteria
command button is currently closing the form and opening a report. The
report is based on a query and the query is run using the strCriteria (which
comes from a text box on the form). The code is below. All of this is
working so far.
*********************************************
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
***********************************************
I want to add the following code to the above command button. I have tried,
and it's not working. I have verified that the SQL query works. I just
don't know how to integrate it into the code I already have. The part that
it's not liking is "WhereCondition:=strCriteria" It works for opening
report/query to view the purchase order. I thought that I could use the same
method for another query. The SQL statement below is a delete query.
qryDeleteBUY_a is a select query.
******* code I want to add to the above ********
'save record
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
'run query
DoCmd.RunSQL "DELETE tblBUY.PART_NO FROM tblBUY WHERE PART_NO IN (SELECT
PART_NO FROM qryDeleteBUY_a);"
WhereCondition:=strCriteria