Need help to save record from excel vba userform to Access database

manissinha

New Member
Joined
Jul 7, 2017
Messages
9
hi

i have create a userform in excel for multiple user to use all at a time and i want to save its input record into Access database. i am able to save it on excel but if multiple user user at same time to save record it giving error , that's why i want to use Access ,
please help to to save record into Access database
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
You CAN make an Access front end for everyone to use simultaneously.
but
if you want, you can make an ADO connection to the access backend using an Excel front end entry.
The user clicks SAVE button , then run code....

Code:
sub Save_click()
Dim conn as new ADO.connection

conn.connectionstring= ".....your data..."

SSql=" insert into table (field1,field2) values ('" & txtBox1 & "'," & txtBox2 & ")"
Conn.execute sSql
Conn.close
set conn= nothing
end sub
 
Last edited:
Upvote 0
Hi ranman..

I am getting an error on this..
Could please help me solve this..
Error getting.."operation is not allowed when object is closed"
Even thogh i kept access db open.
Code:
Dim conn As New ADODB.Connection
Dim sSql


conn.connectionstring = "\\group$\Common\Dashboard\Pankaj\H&B\Timesheet_Data.accdb"


sSql = " insert into Table1 (Start Date/Time,Closed Date/Time,Activity Type,Sub Type,Case ID,EE Tool TimeDate,Project ID,Project Name,Task ID,Task Name,Comments,User name) values ('" & txtstartdate & "',DateTime.Now, " & cmbActivity & "," & ComboBox1 & "," & TxtCaseID & "," & TxtEETime & "," & TxtProjectID & "," & TxtProjectName & "," & TxtTaskID & "," & TxtTaskName & "," & cmbTaskStatus & "," & txtcomm & ")"
conn.Execute sSql
conn.Close
Set conn = Nothing

You CAN make an Access front end for everyone to use simultaneously.
but
if you want, you can make an ADO connection to the access backend using an Excel front end entry.
The user clicks SAVE button , then run code....

Code:
sub Save_click()
Dim conn as new ADO.connection

conn.connectionstring= ".....your data..."

SSql=" insert into table (field1,field2) values ('" & txtBox1 & "'," & txtBox2 & ")"
Conn.execute sSql
Conn.close
set conn= nothing
end sub
 
Upvote 0
Code:
Dim conn As New ADODB.Connection
Dim sSql


conn.connectionstring = "\\group$\Common\Dashboard\Pankaj\H&B\Timesheet_Data.accdb"


sSql = " insert into Table1 (Start Date/Time,Closed Date/Time,Activity Type,Sub Type,Case ID,EE Tool TimeDate,Project ID,Project Name,Task ID,Task Name,Comments,User name) values ('" & txtstartdate & "',DateTime.Now, " & cmbActivity & "," & ComboBox1 & "," & TxtCaseID & "," & TxtEETime & "," & TxtProjectID & "," & TxtProjectName & "," & TxtTaskID & "," & TxtTaskName & "," & cmbTaskStatus & "," & txtcomm & ")"
conn.Execute sSql
conn.Close
Set conn = Nothing

Hi,
You never opened the connection anywhere in this code. The ADO connection.
 
Upvote 0
Isn't what's going on here called hijacking a thread? Isn't that supposed to be discouraged? I realize it's remotely possible that a year later the OP has changed their handle, but probably not the case here.
 
Upvote 0

Forum statistics

Threads
1,214,551
Messages
6,120,156
Members
448,948
Latest member
spamiki

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