473,386 Members | 1,753 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Append Data To Table From Excel

There is an Access table on the network. 15 users who do not have Access are
connected to the network. Is there a way for each user to be able to enter one
or more rows containing 3 or 4 columns to Excel on his machine and then press a
button or something and append that data to the Access table on the network? Any
suggestions on what the code would be?

Thank you very much!

Martin
Nov 12 '05 #1
4 13441
One way you could handle this is to create a user form for the Excel sheet
that has the data on it. The form would simply have a command button on it
with the following code attached to its on click event:

Private Sub CommandButton1_Click()
'declare variables for ado connection and sql command
Dim oCon, strSql

'these variables will store data from excel spreadsheet
Dim strLastName As String, strFirstName As String, strTitle As String

'instantiate the connection object, and specify connection properties
Set oCon = CreateObject("adodb.connection")
oCon.provider = "microsoft.jet.oledb.4.0"

'open the connection
'you can use a UNC to a file on a server
'ex: \\myserver\data\employees.mdb"
oCon.Open "C:\temp\employees.mdb"

'my spreadsheet data starts on second row. first row contains headers,
so i'm ignoring that
Dim intRow As Integer
intRow = 2

'stop the process as soon as we run out of data in the excel spreadsheet
While Not Sheet1.Cells(intRow, 1) = ""

'assign values from spreadsheet to our variables
strLastName = Sheet1.Cells(intRow, 1)
strFirstName = Sheet1.Cells(intRow, 2)
strTitle = Sheet1.Cells(intRow, 3)

'construct an insert query using our spreadsheet values
strSql = "insert into employees(lastname,firstname,title) values('"
& _
strLastName & "','" & strFirstName & "','" & strTitle & "');"

'execute the sql command
oCon.Execute strSql

'advance our counter to the next row number and activate the first
cell
intRow = intRow + 1
Sheet1.Cells(intRow, 1).Activate
Wend
'close and destroy our ado objects
oCon.Close
Set oCon = Nothing
End Sub

This worked ok in office xp... I think it would work in 2000.

Anyway, I hope this helps.
-Mike

"Martin" <md******@earthlink.net> wrote in message
news:Cx***************@newsread1.news.atl.earthlin k.net...
There is an Access table on the network. 15 users who do not have Access are connected to the network. Is there a way for each user to be able to enter one or more rows containing 3 or 4 columns to Excel on his machine and then press a button or something and append that data to the Access table on the network? Any suggestions on what the code would be?

Thank you very much!

Martin

Nov 12 '05 #2
Mike,

Thanks for a great response!!!

Martin
"Mike S." <do******@noresponse.com> wrote in message
news:Bs***********************@bgtnsc04-news.ops.worldnet.att.net...
One way you could handle this is to create a user form for the Excel sheet
that has the data on it. The form would simply have a command button on it
with the following code attached to its on click event:

Private Sub CommandButton1_Click()
'declare variables for ado connection and sql command
Dim oCon, strSql

'these variables will store data from excel spreadsheet
Dim strLastName As String, strFirstName As String, strTitle As String

'instantiate the connection object, and specify connection properties
Set oCon = CreateObject("adodb.connection")
oCon.provider = "microsoft.jet.oledb.4.0"

'open the connection
'you can use a UNC to a file on a server
'ex: \\myserver\data\employees.mdb"
oCon.Open "C:\temp\employees.mdb"

'my spreadsheet data starts on second row. first row contains headers,
so i'm ignoring that
Dim intRow As Integer
intRow = 2

'stop the process as soon as we run out of data in the excel spreadsheet
While Not Sheet1.Cells(intRow, 1) = ""

'assign values from spreadsheet to our variables
strLastName = Sheet1.Cells(intRow, 1)
strFirstName = Sheet1.Cells(intRow, 2)
strTitle = Sheet1.Cells(intRow, 3)

'construct an insert query using our spreadsheet values
strSql = "insert into employees(lastname,firstname,title) values('"
& _
strLastName & "','" & strFirstName & "','" & strTitle & "');"

'execute the sql command
oCon.Execute strSql

'advance our counter to the next row number and activate the first
cell
intRow = intRow + 1
Sheet1.Cells(intRow, 1).Activate
Wend
'close and destroy our ado objects
oCon.Close
Set oCon = Nothing
End Sub

This worked ok in office xp... I think it would work in 2000.

Anyway, I hope this helps.
-Mike

"Martin" <md******@earthlink.net> wrote in message
news:Cx***************@newsread1.news.atl.earthlin k.net...
There is an Access table on the network. 15 users who do not have Access

are
connected to the network. Is there a way for each user to be able to enter

one
or more rows containing 3 or 4 columns to Excel on his machine and then

press a
button or something and append that data to the Access table on the

network? Any
suggestions on what the code would be?

Thank you very much!

Martin


Nov 12 '05 #3
Mike,

A twist to my original post ---

I found the way to build an HTML form with the text fields I need. Would you
know the code to attach to the Submit button to add the data in the text fields
to the table in the Access database on an intranet.

I'm asking here because I'm wondering if your ADO connection would be used.

Thanks for all your help!

Martin
"Martin" <md******@earthlink.net> wrote in message
news:sk****************@newsread1.news.atl.earthli nk.net...
Mike,

Thanks for a great response!!!

Martin
"Mike S." <do******@noresponse.com> wrote in message
news:Bs***********************@bgtnsc04-news.ops.worldnet.att.net...
One way you could handle this is to create a user form for the Excel sheet
that has the data on it. The form would simply have a command button on it
with the following code attached to its on click event:

Private Sub CommandButton1_Click()
'declare variables for ado connection and sql command
Dim oCon, strSql

'these variables will store data from excel spreadsheet
Dim strLastName As String, strFirstName As String, strTitle As String

'instantiate the connection object, and specify connection properties
Set oCon = CreateObject("adodb.connection")
oCon.provider = "microsoft.jet.oledb.4.0"

'open the connection
'you can use a UNC to a file on a server
'ex: \\myserver\data\employees.mdb"
oCon.Open "C:\temp\employees.mdb"

'my spreadsheet data starts on second row. first row contains headers,
so i'm ignoring that
Dim intRow As Integer
intRow = 2

'stop the process as soon as we run out of data in the excel spreadsheet
While Not Sheet1.Cells(intRow, 1) = ""

'assign values from spreadsheet to our variables
strLastName = Sheet1.Cells(intRow, 1)
strFirstName = Sheet1.Cells(intRow, 2)
strTitle = Sheet1.Cells(intRow, 3)

'construct an insert query using our spreadsheet values
strSql = "insert into employees(lastname,firstname,title) values('"
& _
strLastName & "','" & strFirstName & "','" & strTitle & "');"

'execute the sql command
oCon.Execute strSql

'advance our counter to the next row number and activate the first
cell
intRow = intRow + 1
Sheet1.Cells(intRow, 1).Activate
Wend
'close and destroy our ado objects
oCon.Close
Set oCon = Nothing
End Sub

This worked ok in office xp... I think it would work in 2000.

Anyway, I hope this helps.
-Mike

"Martin" <md******@earthlink.net> wrote in message
news:Cx***************@newsread1.news.atl.earthlin k.net...
There is an Access table on the network. 15 users who do not have Access

are
connected to the network. Is there a way for each user to be able to enter

one
or more rows containing 3 or 4 columns to Excel on his machine and then

press a
button or something and append that data to the Access table on the

network? Any
suggestions on what the code would be?

Thank you very much!

Martin



Nov 12 '05 #4
Mike,

Sorry, I posted in the wrong place the first time.

A twist to my original post ---

I found the way to build an HTML form with the text fields I need. Would you
know the code to attach to the Submit button to add the data in the text fields
to the table in the Access database on an intranet.

I'm asking here because I'm wondering if your ADO connection would be used.

Thanks for all your help!

Martin

"Mike S." <do******@noresponse.com> wrote in message
news:Bs***********************@bgtnsc04-news.ops.worldnet.att.net...
One way you could handle this is to create a user form for the Excel sheet
that has the data on it. The form would simply have a command button on it
with the following code attached to its on click event:

Private Sub CommandButton1_Click()
'declare variables for ado connection and sql command
Dim oCon, strSql

'these variables will store data from excel spreadsheet
Dim strLastName As String, strFirstName As String, strTitle As String

'instantiate the connection object, and specify connection properties
Set oCon = CreateObject("adodb.connection")
oCon.provider = "microsoft.jet.oledb.4.0"

'open the connection
'you can use a UNC to a file on a server
'ex: \\myserver\data\employees.mdb"
oCon.Open "C:\temp\employees.mdb"

'my spreadsheet data starts on second row. first row contains headers,
so i'm ignoring that
Dim intRow As Integer
intRow = 2

'stop the process as soon as we run out of data in the excel spreadsheet
While Not Sheet1.Cells(intRow, 1) = ""

'assign values from spreadsheet to our variables
strLastName = Sheet1.Cells(intRow, 1)
strFirstName = Sheet1.Cells(intRow, 2)
strTitle = Sheet1.Cells(intRow, 3)

'construct an insert query using our spreadsheet values
strSql = "insert into employees(lastname,firstname,title) values('"
& _
strLastName & "','" & strFirstName & "','" & strTitle & "');"

'execute the sql command
oCon.Execute strSql

'advance our counter to the next row number and activate the first
cell
intRow = intRow + 1
Sheet1.Cells(intRow, 1).Activate
Wend
'close and destroy our ado objects
oCon.Close
Set oCon = Nothing
End Sub

This worked ok in office xp... I think it would work in 2000.

Anyway, I hope this helps.
-Mike

"Martin" <md******@earthlink.net> wrote in message
news:Cx***************@newsread1.news.atl.earthlin k.net...
There is an Access table on the network. 15 users who do not have Access

are
connected to the network. Is there a way for each user to be able to enter

one
or more rows containing 3 or 4 columns to Excel on his machine and then

press a
button or something and append that data to the Access table on the

network? Any
suggestions on what the code would be?

Thank you very much!

Martin


Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Kevin | last post by:
Hi I have a table that is imported from excel the records are updated as required by the user my question is Can only the new data entered be appended to the table in access ie if i update the...
1
by: socasteel21 via AccessMonster.com | last post by:
I have a spreadsheet that has 3 tabs each of the worksheets is setup exactly like a cooresponding table in Access. I created a button that should import each tab to a new table and then append...
3
by: wvmbark | last post by:
First time poster... I just found this forum and it appears there's plenty of people here that could make short work of problem that's been driving me absolutely bonkers for months. Every day we...
8
by: DongningLi | last post by:
At month end, there will be a month-to-date table that should be appended into the Year-to-date one. The MTD table is a lump-sum one, no way to enter into the YTD one entry by one entry. I can...
2
by: SePp | last post by:
Hi, I have one dataset which is exported to an external file (excel) My problem is that I want to append the data of two different views to one dataset. (because they have to be displayed in an...
4
by: franc sutherland | last post by:
Hello, I am using Access 2003. I am having trouble trapping the "can't append all the records in the append query" error message when appending data to a query from a table which is linked to...
10
by: MeeMee | last post by:
Hi I have a problem appending data into an oracle table from access. I imported the new data from an excel sheet into a table in access and useed an append query to add the data into a linked...
2
by: AccessHunter | last post by:
Please advice me on this. I need to create a new access database that will used to collect the employee hours from various locations. Every friday supervisors from various locations will be sending...
24
by: MNNovice | last post by:
I am working on a DB to record expenses related to various grants. To record Payroll expenses I created tblPayroll with these fields: PayrollID – auto / PK ECHOID – Number FK (tied to tblECHO)...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.