insert delete and update from excel userform to access database - help

rdm34

New Member
Joined
Apr 20, 2015
Messages
4
Hello. could you help me please?

i have code in order to record data into access database, it works good but i dont know how to do delete and update...


Dim dbConnection As ADODB.Connection
Dim recordSet As ADODB.recordSet
Dim strSQL As String


Set dbConnection = New ADODB.Connection
Set recordSet = New ADODB.recordSet


Material = Me.Material.Value
Unit = Me.Unit.Value
UnitPrice = Me.UnitPrice.Value
Curr = Me.Curr.Value
Supplier = Me.Supplier.Value
Origin = Me.Origin.Value


dbConnection.Open "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=\\Database\MechAndElecDatabase.accdb"
dbConnection.CursorLocation = adUseClient


strSQL = "INSERT INTO MechAndElecMalzeme ([Material],[Unit],[UnitPrice],[Curr],[Supplier],[Origin]) VALUES ('" & Material & "','" & Unit & "','" & UnitPrice & "','" & Curr & "','" & Supplier & "','" & Origin & "')"


recordSet.Open strSQL, dbConnection


dbConnection.Close
Set dbConnection = Nothing
MsgBox "Record added.."
 
Last edited:

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Forum statistics

Threads
1,214,837
Messages
6,121,883
Members
449,057
Latest member
Moo4247

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top