Solved

How can I transfer data from MS Word to MS SQL tables?

Posted on 2016-11-04
4
38 Views
Last Modified: 2016-11-04
Hi there,
I would like to use MS Word to provide customers with a specific form.
When they have filled in this form, I would like to transfer the contents (fields) to a SQL database (Microsoft SQL).
How can I do this?
Kind Regards,
Stefan
0
Comment
Question by:Stefan van Roosmalen
  • 2
  • 2
4 Comments
 
LVL 13

Expert Comment

by:John Tsioumpris
ID: 41873981
Usually its the other way around but is possible if you create a form and when the user fills the data to connect to MySQL and upload the data
So you need to start here in order to create a fillable form...
Then you get the ODBC driver from MySQL in order to establish a connection...
But personally i feel that using Word for this kind of job is somewhat an overkill....
If you have Access its much easier...
0
 

Author Comment

by:Stefan van Roosmalen
ID: 41874017
Hi John, thanks for your feedback.
Actually, making a form is not the problem. The real issue is how to transfer to MS SQL.
Can you help me with that?
0
 
LVL 13

Accepted Solution

by:
John Tsioumpris earned 500 total points
ID: 41874042
I guess you could go like this on a click event
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Set conn = New ADODB.Connection

conn.connectionString = "DRIVER={MySQL ODBC 3.51 Driver};"_
& "SERVER=localhost;"_
& " DATABASE=test;"_
& "UID=venu;PWD=venu; OPTION=3"
conn.CursorLocation = adUseClient
    conn.Open
    Set rs = New ADODB.Recordset
 rs.Open "select  * FROM YourTable where AA=10;", conn, adOpenStatic, adLockOptimistic
rs.AddNew
rs!fieldA= ValueA
......
rs!fieldX= ValueX
rs.Update

rs.close
conn.close

Open in new window

Check the driver version in order for the connection string to work
0
 

Author Closing Comment

by:Stefan van Roosmalen
ID: 41874081
Thanks! This is the way to go...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A few years ago I was very much a beginner at VBA, and that very much remains the case today.  I'll do my best to explain things as I go in the hope that other beginners can follow.  If you just want to check out a tool that creates a Select Case fu…
This is written from a 'VBA for MS Word' perspective, but I am sure it applies to most other MS Office components where VBA is used.  One thing that really bugs me is slow code, ESPECIALLY when it's mine!  In programming there are so many ways to…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now