Appending from form to table

S

Stu Kennedy

I have a selection form that moves info from one list box to another and I
need to add the data from the second box to an existing table, then go to
another form. Here is the code I have, but I don't know how to append the
fields from the list box to my existing table:

Private Sub OK_Click()
Dim CurDB As Database, SelectPhys As Database, Rs As Recordset, Rs1 As
Recordset, SQLStmt As String, SQLStmt1 As String
Dim SelPhys As String
SelPhys = ""
Set CurDB = CurrentDb()
Set SelectPhys = SelectedPhysicianstoprocess
SQLStmt = "SELECT [PHYS_CODE],[PHYS_NAME] from [phys_name_select] where
[PHYS_SELECTED] = True ORDER BY [PHYS_CODE]"
Set Rs = CurDB.OpenRecordset(SQLStmt, DB_OPEN_DYNASET)
Set Rs1 = SelectPhys.OpenRecordset(Rs1, DB_Append_Only)
Do While Not Rs.EOF
SelPhys = SelPhys & Rs("PHYS_CODE") & " "
Rs.MoveNext
Fields.Append PHYS_CODE, Text
Fields.Append PHYS_NAME, Text
Loop
Rs.Close
End Sub

any and all help is greatly appreciated!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top