is a new record with only the SL_Client_No field updated/incremented (SL0002).
Then i want to copy fields from existing form (Me![First_Name]) about 10
fields on current form and then the value from a combo box on the same form.
Is this a bound form? Why *from a form* rather than from a table? Data is NOT
stored in forms! Are you perhaps loading a bound (or unbound???) form from one
table and exporting the data to another table?
If you're copying the data from one table to another table, an Append query
executed from code would be preferred. If you indeed must use the form as an
intermediary, there are a few ways to do it, none ideal - an Append query with
ten parameters from the form, or opening a Recordset based on the target table
and populating it in code... both rather difficult to do and even harder to
maintain.
As an Append query, assuming you have data in tblProspects, that you have one
of those records selected on the form, and you want to copy all of the fields
except the SL_Client_No, something like this should work:
Private Sub cmd_CreateClient_Click()
Dim strSQL As String
Dim db As DAO.Database
Dim qd As DAO.Querydef
Dim strNextID As String
On Error GoTo Proc_Err
strNextID = "SL" & Format(Val(Right, DMax("SL_Client_No", [Clients]), 4) _
+ 1, "0000")
Set db = CurrentDb
strSQL = "INSERT INTO Clients ([SL_Client_No], [thisfield], [thatfield])" _
" SELECT '" & strNextID & "' AS SL_Client_No, [thisfield], [thatfield]" _
" FROM Prospects WHERE DL_Prospect_No = '" _
& Forms!yourformname!DL_Prospect_No & "';"
Set qd = db.CreateQuerydef("", strSQL)
qd.Execute dbFailOnError
Proc_Exit:
Exit Sub
Proc_Err:
MsgBox "Error " & Err.Number & " in cmd_CreateClient_Click:" & vbCrLf _
& Err.Description
Resume Proc_Exit
End Sub
John W. Vinson [MVP]