N
NEWER USER
I am have been trying to eliminate having to delete and then redefine my
query in the code below. Can anyone help or suggest how I would modify?
Private Sub Text0_AfterUpdate()
On Error GoTo Err_Text0_AfterUpdate
Dim stDocName1 As String
Dim stDocName2 As String
Dim MyQueryDef As QueryDef
Dim db As DAO.Database
Set db = CurrentDb()
If ObjectExists("Queries", "qryUpdateBRSales") = True Then
db.QueryDefs.Delete "qryUpdateBRSales"
End If
If ObjectExists("Queries", "qryUpdateStatus") = True Then
db.QueryDefs.Delete "qryUpdateStatus"
End If
Set MyQueryDef = db.CreateQueryDef("qryUpdateBRSales", "UPDATE
[tblSales] INNER JOIN tblProduct ON [tblSales].ProductID =
tblProduct.ProductID SET tblProduct.BRSales = [" +
Forms!frmSelectColumn!Text0 + "]")
Set MyQueryDef = db.CreateQueryDef("qryUpdateStatus", "UPDATE
[tblStatus] INNER JOIN tblProduct ON [tblStatus].ProductID =
tblProduct.ProductID SET tblProduct.Status = [" + Forms!frmSelectColumn!Text0
+ "]")
stDocName1 = "qryUpdateBRSales"
stDocName2 = "qryUpdateStatus"
DoCmd.SetWarnings False
DoCmd.OpenQuery stDocName1, acNormal, acEdit
DoCmd.OpenQuery stDocName2, acNormal, acEdit
DoCmd.SetWarnings True
DoCmd.Close
Exit_Text0_AfterUpdate:
Exit Sub
Err_Text0_AfterUpdate:
MsgBox Err.Description
Resume Exit_Text0_AfterUpdate
End Sub
query in the code below. Can anyone help or suggest how I would modify?
Private Sub Text0_AfterUpdate()
On Error GoTo Err_Text0_AfterUpdate
Dim stDocName1 As String
Dim stDocName2 As String
Dim MyQueryDef As QueryDef
Dim db As DAO.Database
Set db = CurrentDb()
If ObjectExists("Queries", "qryUpdateBRSales") = True Then
db.QueryDefs.Delete "qryUpdateBRSales"
End If
If ObjectExists("Queries", "qryUpdateStatus") = True Then
db.QueryDefs.Delete "qryUpdateStatus"
End If
Set MyQueryDef = db.CreateQueryDef("qryUpdateBRSales", "UPDATE
[tblSales] INNER JOIN tblProduct ON [tblSales].ProductID =
tblProduct.ProductID SET tblProduct.BRSales = [" +
Forms!frmSelectColumn!Text0 + "]")
Set MyQueryDef = db.CreateQueryDef("qryUpdateStatus", "UPDATE
[tblStatus] INNER JOIN tblProduct ON [tblStatus].ProductID =
tblProduct.ProductID SET tblProduct.Status = [" + Forms!frmSelectColumn!Text0
+ "]")
stDocName1 = "qryUpdateBRSales"
stDocName2 = "qryUpdateStatus"
DoCmd.SetWarnings False
DoCmd.OpenQuery stDocName1, acNormal, acEdit
DoCmd.OpenQuery stDocName2, acNormal, acEdit
DoCmd.SetWarnings True
DoCmd.Close
Exit_Text0_AfterUpdate:
Exit Sub
Err_Text0_AfterUpdate:
MsgBox Err.Description
Resume Exit_Text0_AfterUpdate
End Sub