C
cvegas
I am trying to update records in my table that are marked "Completed" prior
to running an Invoice Report
I have been working on this all day and could use any help you might want to
give.
Hopefully I have given you enough info to figure out what it is I am trying
to accomplish
'Select Records whose status is marked as "Completed" and order by the
OrderId number
SELECT '<-- This part is red in the VB window and appears not to be correct?
dbo_FDRShipments.OrderID , dbo_FDRShipments.OrderDate,
dbo_FDRShipments.Status_
dbo_FDRShipments.InvoiceNumber , dbo_FDRShipments.InvoiceDate_
dbo_FDRShipments.InvoiceAmount , dbo_FDRShipments.QuoteToCustomer_
FROM dbo_FDRShipments
WHERE (((dbo_FDRShipments.Status) = "Completed"))
ORDER BY dbo_FDRShipments.OrderID;'<-- This part is red in the VB window
'Determine the last Invoice Number Part that was used
'There is always only 1 record in this table which has 2 fields
[ID],[InvNumPart]
Dim lastnumber As Variant
lastnumber = DLookup("[InvNumPart]", "dbo_InvNumPart") + 1
'Go into the records that were selected and insert the proper information
into each record
'Need additional help here with syntax. Not sure how to insert data only
into the
'selected records.
Dim db As Database
Dim rst As Recordset
Set db = CurrentDb()
Set rst = db.OpenRecordset("dbo_FDRShipments") '??Dont know if this is
correct?
'Need to go to the 1st record in the selected records and insert the
following info
rst.Edit
rst![InvoiceNumber] = lastnumber
rst![InvoiceDate] = Date
rst![Status] = "Invoiced"
rst.Update
'Increase the lastnumber by 1 before going to the next record
lastnumber = lastnumber + 1
'Move to the next record that meets the select criteria and do the same as
above
'Once all records matching the select critera are updated
'Update the data in the table InvNumPart
Set rst = db.OpenRecordset("dbo_invnumpart")
rst.MoveFirst
rst.Edit
rst![InvNumPart] = lastnumber
rst.Update
rst.Close
Set rst = Nothing
Set db = Nothing
to running an Invoice Report
I have been working on this all day and could use any help you might want to
give.
Hopefully I have given you enough info to figure out what it is I am trying
to accomplish
'Select Records whose status is marked as "Completed" and order by the
OrderId number
SELECT '<-- This part is red in the VB window and appears not to be correct?
dbo_FDRShipments.OrderID , dbo_FDRShipments.OrderDate,
dbo_FDRShipments.Status_
dbo_FDRShipments.InvoiceNumber , dbo_FDRShipments.InvoiceDate_
dbo_FDRShipments.InvoiceAmount , dbo_FDRShipments.QuoteToCustomer_
FROM dbo_FDRShipments
WHERE (((dbo_FDRShipments.Status) = "Completed"))
ORDER BY dbo_FDRShipments.OrderID;'<-- This part is red in the VB window
'Determine the last Invoice Number Part that was used
'There is always only 1 record in this table which has 2 fields
[ID],[InvNumPart]
Dim lastnumber As Variant
lastnumber = DLookup("[InvNumPart]", "dbo_InvNumPart") + 1
'Go into the records that were selected and insert the proper information
into each record
'Need additional help here with syntax. Not sure how to insert data only
into the
'selected records.
Dim db As Database
Dim rst As Recordset
Set db = CurrentDb()
Set rst = db.OpenRecordset("dbo_FDRShipments") '??Dont know if this is
correct?
'Need to go to the 1st record in the selected records and insert the
following info
rst.Edit
rst![InvoiceNumber] = lastnumber
rst![InvoiceDate] = Date
rst![Status] = "Invoiced"
rst.Update
'Increase the lastnumber by 1 before going to the next record
lastnumber = lastnumber + 1
'Move to the next record that meets the select criteria and do the same as
above
'Once all records matching the select critera are updated
'Update the data in the table InvNumPart
Set rst = db.OpenRecordset("dbo_invnumpart")
rst.MoveFirst
rst.Edit
rst![InvNumPart] = lastnumber
rst.Update
rst.Close
Set rst = Nothing
Set db = Nothing