Is it possible to save excel userform data into Access

manissinha

New Member
Joined
Jul 7, 2017
Messages
9
Hi

I have created a user form in excel vba for multi user is is possible to save its data into Access.

thanks
Manish
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
It is possible, something like this:

Code:
    Dim cn As New ADODB.Connection
    Dim cs As String
    Dim rs1 As New ADODB.Recordset
    cs = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=[COLOR=#ff0000]C:\MyDatabase.accdb[/COLOR]"
    cn.Open cs
    rs1.Open "[COLOR=#FF0000]MyTable[/COLOR]", cn, adOpenDynamic, adLockOptimistic
        
    With rs1
        .AddNew
        .Fields("[COLOR=#FF0000]myField1[/COLOR]") = Me.[COLOR=#FF0000]MyTextBox1[/COLOR]
        .Fields("[COLOR=#FF0000]MyField2[/COLOR]") = Me.[COLOR=#FF0000]MyTextBox2[/COLOR]
        .Update
    End With
  
  
Set rs1 = Nothing
cn.Close
Set cn = Nothing

The red part will need to be changed to meet your needs. Also in this example I have a table as the recordset - you can also use SQL for this.
 
Upvote 0

Forum statistics

Threads
1,221,687
Messages
6,161,287
Members
451,695
Latest member
Doug Mize 1024

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