Reputation: 1055
I currently have a form in which I have alot of text and comboboxes. For this example I am only going to focus on two of them "QuoteID" and "Contact".
When I first open my form the QuoteID combobox (Which is the primary Key) says (New) or in other words, the control source for QuoteID combobox is set to the QuoteID (PK) in the table. I want the form to have (New) for the primary key when it first opens.
Contact is a textbox; its control source is set to contact in the table.
I currently have data entry = yes and cycle = current record.
My goal is when I am working on a new quote I want to be able to save the current record that I am working on, and then once saved I can then continue to work on it saving it as I go.
My problem That I am having is; When I click my command button called "Save Quote" It adds the data from the form to the table correctly. When I click it again it adds a new record, giving me multiple instances of the same quote.
Private Sub SaveQuote_Click()
Dim miscQuote As Recordset
Set miscQuote = CurrentDb.OpenRecordset("tblQuotes")
miscQuote.AddNew
miscQuote![Contact] = frmQuote3.Value
miscQuote![QuoteID] = frmQuote1.Value
miscQuote.Update
miscQuote.Close
Set RecSet = Nothing
End Sub
frmQuote3 is a text box and frmQuote1 is a combobox on my form.
Upvotes: 0
Views: 2778
Reputation: 55806
Just set Dirty to False to save the record:
Private Sub SaveQuote_Click()
If Me.Dirty = True Then
Me.Dirty = False
End If
End Sub
Upvotes: 2