Hi, i'm having difficulty updating an existing record in my form. I can enter a docket number on my form and when i hit my button (Find Docket) it brings up all the customers info (name, date, invoice, vat, total, etc.) What i want to do then is be able to amend/update the record. Just wondering do i need to put vba code in my save button and any ideas how to code it and is it similiar to my find data code below. appreciate any help.
Here is my save function code:
Function SaveData() As Boolean
Dim db As Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("Skips Delivered")
rs.AddNew
'rs("No").Value = txtNo
rs("Deliver Docket").Value = txtDel
rs("Customer").Value = cboCust
rs("Name").Value = txtCust
rs("Order Number").Value = txtOrderNumber
rs("Customer Reference").Value = txtCustRef
rs("County").Value = cboCounty
rs("Location").Value = txtLocation
rs("Phone No").Value = txtPhoneNo
rs("Skip No").Value = txtSkipNo
rs("Date Dropped").Value = txtDateDropped
rs("Truck").Value = cboTruck
rs("Date Collected").Value = txtDateCollected
rs("Date Weighed").Value = txtDateWeighed
rs("Waste Code").Value = cboWasteCodes
rs("Weight").Value = txtWeight
rs("Weigh Ticket").Value = txtWeighTicket
rs("Status").Value = cboStatus
rs("Paid By").Value = cboPaidBy
rs("Invoice No").Value = txtInvoice
rs("VAT Code").Value = cboVatCode
rs("Price").Value = txtPrice
rs("VAT Type").Value = txtVatType
rs("Goods").Value = txtInvoiceGoods
rs("Vat").Value = txtInvoiceVat
rs("Total").Value = txtInvoiceTota
SaveData = True
End Function
and here is my Find Data function code:
Function FindData()
Dim rs As DAO.Recordset
Dim strSQL As String
strSQL = "Select * From [Skips Delivered] Where [Deliver Docket] = " & txtDel
Set rs = CurrentDb.OpenRecordset(strSQL)
cboCust = rs("Customer")
txtCust = rs("Name")
txtOrderNumber = rs("Order Number")
txtCustRef = rs("Customer Reference")
cboCounty = rs("County")
txtLocation = rs("Location")
txtPhoneNo = rs("Phone No")
txtSkipNo = rs("Skip No")
txtDateDropped = rs("Date Dropped")
cboTruck = rs("Truck")
txtDateCollected = rs("Date Collected")
txtDateWeighed = rs("Date Weighed")
cboWasteCodes = rs("Waste Code")
txtWeight = rs("Weight")
txtWeighTicket = rs("Weigh Ticket")
cboStatus = rs("Status")
cboPaidBy = rs("Paid By")
txtInvoice = rs("Invoice No")
cboVatCode = rs("VAT Code")
txtPrice = rs("Price")
txtVatType = rs("VAT Type")
txtInvoiceGoods = rs("Goods")
txtInvoiceVat = rs("Vat")
txtInvoiceTotal = rs("Total")
rs.Close
End Function
Here is my save function code:
Function SaveData() As Boolean
Dim db As Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("Skips Delivered")
rs.AddNew
'rs("No").Value = txtNo
rs("Deliver Docket").Value = txtDel
rs("Customer").Value = cboCust
rs("Name").Value = txtCust
rs("Order Number").Value = txtOrderNumber
rs("Customer Reference").Value = txtCustRef
rs("County").Value = cboCounty
rs("Location").Value = txtLocation
rs("Phone No").Value = txtPhoneNo
rs("Skip No").Value = txtSkipNo
rs("Date Dropped").Value = txtDateDropped
rs("Truck").Value = cboTruck
rs("Date Collected").Value = txtDateCollected
rs("Date Weighed").Value = txtDateWeighed
rs("Waste Code").Value = cboWasteCodes
rs("Weight").Value = txtWeight
rs("Weigh Ticket").Value = txtWeighTicket
rs("Status").Value = cboStatus
rs("Paid By").Value = cboPaidBy
rs("Invoice No").Value = txtInvoice
rs("VAT Code").Value = cboVatCode
rs("Price").Value = txtPrice
rs("VAT Type").Value = txtVatType
rs("Goods").Value = txtInvoiceGoods
rs("Vat").Value = txtInvoiceVat
rs("Total").Value = txtInvoiceTota
SaveData = True
End Function
and here is my Find Data function code:
Function FindData()
Dim rs As DAO.Recordset
Dim strSQL As String
strSQL = "Select * From [Skips Delivered] Where [Deliver Docket] = " & txtDel
Set rs = CurrentDb.OpenRecordset(strSQL)
cboCust = rs("Customer")
txtCust = rs("Name")
txtOrderNumber = rs("Order Number")
txtCustRef = rs("Customer Reference")
cboCounty = rs("County")
txtLocation = rs("Location")
txtPhoneNo = rs("Phone No")
txtSkipNo = rs("Skip No")
txtDateDropped = rs("Date Dropped")
cboTruck = rs("Truck")
txtDateCollected = rs("Date Collected")
txtDateWeighed = rs("Date Weighed")
cboWasteCodes = rs("Waste Code")
txtWeight = rs("Weight")
txtWeighTicket = rs("Weigh Ticket")
cboStatus = rs("Status")
cboPaidBy = rs("Paid By")
txtInvoice = rs("Invoice No")
cboVatCode = rs("VAT Code")
txtPrice = rs("Price")
txtVatType = rs("VAT Type")
txtInvoiceGoods = rs("Goods")
txtInvoiceVat = rs("Vat")
txtInvoiceTotal = rs("Total")
rs.Close
End Function