J
Johnkl via AccessMonster.com
Can you tell me why this code is not working???
Private Sub cmdDoCost_Click()
Dim db As DAO.Database
Dim rstPO As DAO.Recordset, rstPORoducts As DAO.Recordset
Dim rstSToOrder As DAO.Recordset, qd As DAO.QueryDef
Dim varRet As Variant, lngPOCount As Long
Dim lngPONum As Long, lngI As Long, intLine As Integer
Dim lngFirstPONum As Long, lngThisVend As Long
Set db = DBEngine(0)(0)
Set rstPO = db.OpenRecordset("tblPurchases", dbOpenDynaset, dbAppendOnly)
Set rstPOServices = db.OpenRecordset("tblPurchaseDetails", dbOpenDynaset,
dbAppendOnly)
Set rstSToOrder = db.OpenRecordset("zqryServicesToOrder")
varRet = SysCmd(acSysCmdInitMeter, "Creating Purchase Orders....", lngSOCount)
rstSToOrder.MoveFirst
Do Until rstSToOrder.EOF
If lngThisVend <> rstSToOrder![ThisVend] Then
If lngThisVend <> 0 Then
CommitTrans
intTrans = False
BeginTrans
intTrans = True
rstPO.AddNew
rstPO!Order_Date = [DateIn]
rstPO!SupplierID = rstSToOrder![ThisVend]
rstPO!File = [FileID]
rstPO!EmployeeID = [EmployeeID]
rstPO.Update
lngThisVend = rstSToOrder![ThisVend]
rstPOServices.AddNew
rstPOServices!ServiceID = rstSToOrder![ServiceID]
rstPOServices.Update
End If
Loop
Exit Do
CommitTrans
DBEngine.Idle dbFreeLocks
End If
End Sub
Thanks for your help
John
Private Sub cmdDoCost_Click()
Dim db As DAO.Database
Dim rstPO As DAO.Recordset, rstPORoducts As DAO.Recordset
Dim rstSToOrder As DAO.Recordset, qd As DAO.QueryDef
Dim varRet As Variant, lngPOCount As Long
Dim lngPONum As Long, lngI As Long, intLine As Integer
Dim lngFirstPONum As Long, lngThisVend As Long
Set db = DBEngine(0)(0)
Set rstPO = db.OpenRecordset("tblPurchases", dbOpenDynaset, dbAppendOnly)
Set rstPOServices = db.OpenRecordset("tblPurchaseDetails", dbOpenDynaset,
dbAppendOnly)
Set rstSToOrder = db.OpenRecordset("zqryServicesToOrder")
varRet = SysCmd(acSysCmdInitMeter, "Creating Purchase Orders....", lngSOCount)
rstSToOrder.MoveFirst
Do Until rstSToOrder.EOF
If lngThisVend <> rstSToOrder![ThisVend] Then
If lngThisVend <> 0 Then
CommitTrans
intTrans = False
BeginTrans
intTrans = True
rstPO.AddNew
rstPO!Order_Date = [DateIn]
rstPO!SupplierID = rstSToOrder![ThisVend]
rstPO!File = [FileID]
rstPO!EmployeeID = [EmployeeID]
rstPO.Update
lngThisVend = rstSToOrder![ThisVend]
rstPOServices.AddNew
rstPOServices!ServiceID = rstSToOrder![ServiceID]
rstPOServices.Update
End If
Loop
Exit Do
CommitTrans
DBEngine.Idle dbFreeLocks
End If
End Sub
Thanks for your help
John