Form design-SQL Insert

thart21

Registered User.
Local time
Yesterday, 23:26
Joined
Jun 18, 2002
Messages
236
I have a form with the following unbound fields:

Side A
15 cbos with the same Row Source (connector1, connector2)

Side B
15 cbos with the same Row Source (same as Side A)

Vendors
6 cbos with the same Row Source (vendor1, vendor2)

Wire
3 groups of 3 fields - same Row Source
cboStyle
cboGauge
cboInsulation

When the Save button is selected I need the following to happen:

All fields in Side A inserted into the Side A table
All fields in Side B inserted into the Side B table
The PK from the newly inserted records in both Side A and Side B, along with
the balance of the data entered on the form to be inserted into my
tblDetails table.

Is this even possible or good db design/process?

The SQL code I have for just inserting into Side A and B will not work as written: I am getting a "Characters found after the end of the SQL statement" message and, if I remove the ";" I get a "Missing ;" message:

Private Sub Command156_Click()

Dim strSQL As String

strSQL = "INSERT INTO SideA(conn1,conn2,conn3) VALUES(cboOne,cboTwo,cboThree);"

strSQL = strSQL & "INSERT INTO SideB(conn1,conn2,conn3)VALUES(cboOneB,cboTwoB,cboThreeB);"

DoCmd.RunSQL strSQL

End Sub

Any suggestions would be helpful.
Thanks,

Toni
 

Attachments

  • connector.jpg
    connector.jpg
    80.4 KB · Views: 142
Toni,

Syntax:

Code:
strSQL = strSQL & "INSERT INTO SideB (conn1, conn2, conn3) " & _
                  "VALUES('" & Me.cboOneB & "', #" & cboTwoB & "#, " & cbo ThreeB & ");"

That inserts a text field, date field, and a numeric field in that order.

The way you had it, SQL would never pick your names out of that string.

btw,
Why all of the extra work with unbound fields?

Wayne
 

Users who are viewing this thread

Back
Top Bottom