=> Need to save auto generated supplierID to Join table

R

Rhonda Fischer

Hello,

On the Save Event I am using VB code to take the
Supplier Name from the form and save it to the Supplier
Table. I then want to follow that with a save to
a table that needs the Supplier ID just saved. How do
I subtract the unique automatically generated supplierID.

Any suggestions would be terrific.

Thank you very much.

Kind Regards
Rhonda



Example:
========

Private Sub cmdSave_Click()

Call filltblSupplier("frmMgmtSupplierNew")
Call filltblSupplierCustomer("frmMgmtSupplierNew")

End Sub



========================================================
Sub filltblSupplier(myForm)
On Error GoTo Err_filltblSupplier
'Form: frmMgmtSupplierNew
'Button: Save

'Declaration
Dim cnn As ADODB.Connection
Dim cmd As ADODB.Command

Set cnn = New ADODB.Connection
Set cmd = New ADODB.Command

'Open the connection
Set cnn = CurrentProject.Connection

'Set up the Command objects's Connection, SQL and
parameter types
With cmd
.ActiveConnection = cnn
.CommandText = "INSERT INTO tblSupplier
(supplierName) VALUES(?)"
.CreateParameter , adChar, adParamInput, 50
End With

cmd.Parameters(0) = Forms(myForm)!txtSupplierName

cmd.Execute

cnn.Close
Set cnn = Nothing
Set cmd = Nothing

Exit_filltblSupplier:
Exit Sub

Err_filltblSupplier:
MsgBox Err.Description
Resume Exit_filltblSupplier

End Sub
 

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