I have a control on my form that copies the contents of a form and a subform to a new record. Here is my code. On my form, how do I find the new record? That is to say, once I copy the record, the "old record" is still the one on my form. I want to move to the "new record" as part of the copy function.
'copy record to new Quote record
intQuoteID = Forms![Bid - Master Form]![Bid - Quote]![Quote ID]
Set dbs = CurrentDb
Set rstQuote = dbs.OpenRecordset("Bid - Quote")
rstQuote.AddNew
intNewQuoteID = rstQuote![Quote ID]
Debug.Print "New Quote ID " & intNewQuoteID
Debug.Print "New Quote ID " & rstQuote![Quote ID]
Debug.Print "Old Quote ID " & intQuoteID
rstQuote![Master Bid ID] = Forms![Bid - Master Form]![Master Project ID]
rstQuote![Other Mfr] = Forms![Bid - Master Form]![Bid - Quote]![Other Mfr]
rstQuote![Comments] = Forms![Bid - Master Form]![Bid - Quote]![Comments]
rstQuote.Update
Forms![Bid - Master Form]![Bid - Quote].Requery
'copy quote items to new quote items records
strSQL = "Select * " & _
"FROM [Bid - Quote Items] " & _
"WHERE [Quote ID] = " & intQuoteID
Set rstOldQuoteItem = dbs.OpenRecordset(strSQL)
Set rstNewQuoteItem = dbs.OpenRecordset("Bid - Quote Items")
Do While Not rstOldQuoteItem.EOF
rstNewQuoteItem.AddNew
rstNewQuoteItem![Quote ID] = intNewQuoteID
Debug.Print "New Quote ID " & rstNewQuoteItem![Quote ID]
rstNewQuoteItem![Quantity] = rstOldQuoteItem![Quantity]
Debug.Print "Qty " & rstOldQuoteItem![Quantity]
rstNewQuoteItem![Description] = rstOldQuoteItem![Description]
Debug.Print "Description " & rstNewQuoteItem![Description]
rstNewQuoteItem![Finish] = rstOldQuoteItem![Finish]
rstNewQuoteItem![Price] = rstOldQuoteItem![Price]
rstNewQuoteItem![Comments] = rstOldQuoteItem![Comments]
Debug.Print "Comment " & rstNewQuoteItem![Comments]
rstNewQuoteItem.Update
rstOldQuoteItem.MoveNext
Loop
Forms![Bid - Master Form]![Bid - Quote]![Bid - Quote Items]
Thanks is advance
Scott
'copy record to new Quote record
intQuoteID = Forms![Bid - Master Form]![Bid - Quote]![Quote ID]
Set dbs = CurrentDb
Set rstQuote = dbs.OpenRecordset("Bid - Quote")
rstQuote.AddNew
intNewQuoteID = rstQuote![Quote ID]
Debug.Print "New Quote ID " & intNewQuoteID
Debug.Print "New Quote ID " & rstQuote![Quote ID]
Debug.Print "Old Quote ID " & intQuoteID
rstQuote![Master Bid ID] = Forms![Bid - Master Form]![Master Project ID]
rstQuote![Other Mfr] = Forms![Bid - Master Form]![Bid - Quote]![Other Mfr]
rstQuote![Comments] = Forms![Bid - Master Form]![Bid - Quote]![Comments]
rstQuote.Update
Forms![Bid - Master Form]![Bid - Quote].Requery
'copy quote items to new quote items records
strSQL = "Select * " & _
"FROM [Bid - Quote Items] " & _
"WHERE [Quote ID] = " & intQuoteID
Set rstOldQuoteItem = dbs.OpenRecordset(strSQL)
Set rstNewQuoteItem = dbs.OpenRecordset("Bid - Quote Items")
Do While Not rstOldQuoteItem.EOF
rstNewQuoteItem.AddNew
rstNewQuoteItem![Quote ID] = intNewQuoteID
Debug.Print "New Quote ID " & rstNewQuoteItem![Quote ID]
rstNewQuoteItem![Quantity] = rstOldQuoteItem![Quantity]
Debug.Print "Qty " & rstOldQuoteItem![Quantity]
rstNewQuoteItem![Description] = rstOldQuoteItem![Description]
Debug.Print "Description " & rstNewQuoteItem![Description]
rstNewQuoteItem![Finish] = rstOldQuoteItem![Finish]
rstNewQuoteItem![Price] = rstOldQuoteItem![Price]
rstNewQuoteItem![Comments] = rstOldQuoteItem![Comments]
Debug.Print "Comment " & rstNewQuoteItem![Comments]
rstNewQuoteItem.Update
rstOldQuoteItem.MoveNext
Loop
Forms![Bid - Master Form]![Bid - Quote]![Bid - Quote Items]
Thanks is advance
Scott