Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do I update a table in Access through VBA and recordsets?

Status
Not open for further replies.

Spyridon

Technical User
Jun 27, 2003
45
US
I have a variable, let's say intSale, that I need to be inserted into my Sales table, in the SalesType field. The variable is a number, being passed into the SalesType field which holds a number value... intSale holds the value of an option selected from an option group on a form. Here's the code I have, I'm just guessing at the cursor and lock types.

Private Sub Form_AfterInsert()
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim intoption1 As Integer
Dim intoption2 As Integer
Dim intvalue As Integer
Dim intvalue1 As Integer
Dim intvalue2 As Integer

Set cnn = New ADODB.Connection
Set rs = New ADODB.Recordset

rs.Open "Sales", cnn, adOpenKeyset, adLockOptimistic, adCmdTable


intoption = [CableOptions]


Select Case intoption1

Case 1
intvalue1 = 0

Case 2
intvalue1 = 1

Case 3
intvalue1 = 2

Case 4
intvalue1 = 3

End Select


intoption2 = [HSIOPTIONS]

Select Case intoption2

Case 1
intvalue2 = 0

Case 2
intvalue2 = 30

Case 3
intvalue2 = 50

End Select

intvalue = intvalue1 + intvalue2

rs.Fields("SalesType").Value = intvalue



End Sub


Thanks,


Michael
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top