Hi,
I'm fairly new to Access building and i've come across a problem that i cannot find a resolution to. Here goes...
I'm trying to create a command button that will 'copy' a record from one table to another
(e.g. tblQuote record to tblServiceContract Record*new)
I've tried an append query but this doesn;t work as my tblServiceContract has a unique primary ID which i need to keep.
There are only certain fields from Quotes that i need to use to create the new record in ServiceContacts and i keep getting key validation error whatever i try. Can anyone please advise??
I've also tried the code below:
Private Sub Command103_Click()
'No value entered
If IsNull(Me.SQNumber) Or Me.SQNumber = "" Then
MsgBox ("Is null or empty")
Else
Dim entry As String
entry = Me.SQNumber
Dim db As Database
Dim rs As DAO.Recordset
Dim rs2 As DAO.Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordset("SELECT * FROM TblQuotes1 WHERE(contractconfirmed = true)")
Set rs2 = db.OpenRecordset("TblServiceAgreements1")
With rs2
.AddNew
.Fields("Frequency") = rs!Frequency
.Fields("SQNumber") = rs!SQNumber
.Fields("Customer_ID") = rs!Customer_ID
.Fields("Price") = rs!Price
.Fields("Site_ID") = rs!Site_ID
.Fields("CoordinatorID") = rs!CoordinatorID
.Fields("Manhours") = rs!Manhours
.Fields("Region_ID") = rs!Region_ID
.Update
.Close
End With
rs.Close
End If
End Sub
Still Learning................