f



Inserting value from MS Word into MS Access

If there are any enlightend souls out there that can help me, I would
greatly appreciate it. I would like to use a macro to take a value and
add it to an access database.

I am having a problem with the very first line of code,
Dim myDatabase as Database, the system does not recognize the Database
object.

PLEASE if there is anyone out there that has a piece of code that
sends info from a word file into a access database... send it to me. I
will Love you forever.
0
9/29/2004 5:44:23 AM
comp.databases.ms-access 42670 articles. 0 followers. Post Follow

8 Replies
1046 Views

Similar Articles

[PageSpeed] 44

Evan wrote:

> If there are any enlightend souls out there that can help me, I would
> greatly appreciate it. I would like to use a macro to take a value and
> add it to an access database.
> 
> I am having a problem with the very first line of code,
> Dim myDatabase as Database, the system does not recognize the Database
> object.

Add a reference to DAO or use an Object variable and late bind it (set 
db=CreateObject("DAO.Database"), although the first way will give you 
intellisense.

-- 

  \\\\\\
   \\  \\    Windows is searching
     \  \    For your sig.
      \  \   Please Wait.
       \__\

0
Trevor
9/29/2004 7:35:01 AM
mmm, I am sorry - I am really new at this... I have added the ADO
reference, and I want to execute this SQL - "insert into documents
(title) values ('testTitle')"

How do I write the actual code, I had it before but then I deleted the
wrong file... now I am back at square one
0
9/30/2004 4:29:57 AM
Evan wrote:
> mmm, I am sorry - I am really new at this... I have added the ADO
> reference, and I want to execute this SQL - "insert into documents
> (title) values ('testTitle')"
> 
> How do I write the actual code, I had it before but then I deleted the
> wrong file... now I am back at square one

I've not done much in thew way of ADO, at least with Access so I don't 
know the connection string to use but it's something like:

Dim cn As New ADODB.Connection
cn.open "connection string here"
cn.Execute "insert..."
cn.close
set cn=nothing

-- 

  \\\\\\
   \\  \\    Windows is searching
     \  \    For your sig.
      \  \   Please Wait.
       \__\

0
Trevor
9/30/2004 7:17:11 AM
"Trevor Best" <nospam@localhost> wrote in message
news:415bb2f3$0$18274$afc38c87@auth.uk.news.easynet.net...

> I've not done much in thew way of ADO, at least with Access so I don't
> know the connection string to use but it's something like:
>
> Dim cn As New ADODB.Connection
> cn.open "connection string here"
> cn.Execute "insert..."
> cn.close
> set cn=nothing


With ADO in A2000+,

Dim cnxn As ADODB.Connection
Set cnxn = CurrentProject.Connection
cnxn.Execute "INSERT ..."

This works in MDB, not just ADP.  I have seen no benefit in closing this
connection (quite the contrary) or setting it to nothing.  There is a
benefit in closing and setting recordsets to nothing, of course.



Darryl Kerkeslager


0
kerkeslager (601)
9/30/2004 12:52:52 PM
Darryl Kerkeslager wrote:
> With ADO in A2000+,
> 
> Dim cnxn As ADODB.Connection
> Set cnxn = CurrentProject.Connection
> cnxn.Execute "INSERT ..."
> 
> This works in MDB, not just ADP.  I have seen no benefit in closing this
> connection (quite the contrary) or setting it to nothing.  There is a
> benefit in closing and setting recordsets to nothing, of course.

The OP wants to do this from MS Word, so CurrentProject.Connection won't 
work :-( It would also be an idea to close it afterwards from there.

BTW I would close the connection in Access if it were a local variable, 
I know it just points to an already established connection but it's 
still a variable and uses resources, which I wouldn't trust Access VBA 
alone to clean it up and release. Too often with all the apps I run, the 
system's using 256MB RAM after I close all apps, when I boot up it's 
using 128MB so something somewhere is using 128MB RAM and not releasing 
it, I wouldn't try to compound that by not cleaning up my variables, 
it's bad enough in Windows without me being sloppy and adding to the 
problem.

In general, like when I use DAO I have a global Database variable that I 
set to the currentdb. This remains available for instant use all the 
time from anywhere without having to Set/Open, etc before use. Then I 
clean it up before exiting the app.

-- 

  \\\\\\
   \\  \\    Windows is searching
     \  \    For your sig.
      \  \   Please Wait.
       \__\

0
Trevor
9/30/2004 7:30:15 PM
> Darryl Kerkeslager wrote:
> >
> > Dim cnxn As ADODB.Connection
> > Set cnxn = CurrentProject.Connection
> > cnxn.Execute "INSERT ..."
> >
> > This works in MDB, not just ADP.  I have seen no benefit in closing this
> > connection (quite the contrary) or setting it to nothing.  There is a
> > benefit in closing and setting recordsets to nothing, of course.

>"Trevor Best" <nospam@localhost> wrote:
>
> BTW I would close the connection in Access if it were a local variable,
> I know it just points to an already established connection but it's
> still a variable and uses resources, which I wouldn't trust Access VBA
> alone to clean it up and release.

The reason I say not to close it is perhaps a quirk of Access, but enough of
a headache for me that I said, "never again":  setting the connection to
nothing inside a nested call set the outer connection to nothing as well.
Now, perhaps it was my mistake, and I had used a public cnxn variable, as I
do now - I don't remember - but having to worry about whether my function is
being called by anotehr function using CurrentProject.Connection was too
much effort.

Public cnxn As ADODB.Connection

Private Sub Form_Open()
     Set cnxn = CurrentProject.Connection
     If CalledFunction() then
         cnxn.Execute "INSERT ..."
     endif
End Sub

Private Function CalledFunction() As Boolean
     Set cnxn = CurrentProject.Connection
     cnxn.Execute "DELETE * FROM ..."
     Set cnxn = Nothing                            <-- closes open
connection, creating error in Form_Open
End Function


> Then I  clean it up before exiting the app.

I could do this, I suppose, but my feeling has been that if it is only one
connection object, no big deal.  As I said, I do Set all recordsets =
Nothing when I use them.


Darryl Kerkeslager



0
kerkeslager (601)
9/30/2004 11:02:55 PM
Darryl Kerkeslager wrote:

>>Then I  clean it up before exiting the app.
> 
> 
> I could do this, I suppose, but my feeling has been that if it is only one
> connection object, no big deal.  As I said, I do Set all recordsets =
> Nothing when I use them.

I do sometimes wonder I bother with the closing and setting to nothing 
of a global db variable at the end. I have such db variable opened with 
OpenDatabase() to a SQL Server, when I close my app, I close this 
connection and set it to nothing. Then even when I close the database 
(the actual database window so no mdb is open in Access) my connection 
is still there.

As a further test, if I first log onto SQL server as plebe, then close 
the mdb (closing ans setting to nothing my db variable to the sql 
server) and reopen and log on as "sa", I can't do sa type things. This 
could cause a severe security breach the other way around, i.e. plebe 
could have sa privileges.

-- 

  \\\\\\
   \\  \\    Windows is searching
     \  \    For your sig.
      \  \   Please Wait.
       \__\

0
Trevor
10/1/2004 12:43:53 AM
"Trevor Best" <nospam@localhost> wrote:
>
> As a further test, if I first log onto SQL server as plebe, then close
> the mdb (closing ans setting to nothing my db variable to the sql
> server) and reopen and log on as "sa", I can't do sa type things. This
> could cause a severe security breach the other way around, i.e. plebe
> could have sa privileges.
>

I'm not very familiar with SQL Server, but this sounds kinda bad...



0
kerkeslager (601)
10/1/2004 3:08:54 AM
Reply:

Similar Artilces:

Any MS Access that is NOT MS Access in WinXP?
Hi all, I have a small application for bookkeeping, actually working in Access with small routines in VBA. I want to rewrite it in Java, but I don't want to use Access anymore. I started looking for another database, but I found none. I already know (and used) MySQL and PostgreSQL (waiting 7.4), but as far as I know they are only daemon, and under windows they use a lot of memory and CPU time. It's like installing a Ferrari only to cross the road. Maybe an approach with loading the daemon at the start of the program, and quitting it at the end, but I don't know how ...

Create MS/ACCESS database app for non-ms/access users
Is it possible to create an MS/ACCESS database application and package it for users who do not have MS/ACCESS loaded in their PCs? I was told that this is possible, but I don't know what software is needed. Do you know? If so, please answer this post. Thanks. SueB *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! Per Sue Bricker: >Is it possible to create an MS/ACCESS database application and package >it for users who do not have MS/ACCESS loaded in their PCs? > >I was told that this is possible, but...

Possible to keep MS Access interface and migrate the MS Access to MS SQL Server?
Hello all Would it be possible to migrate the MS Access 2000 to MS SQL Server 2000? My application is using MS Access 2000 as database and as user interface such as forms. Now, I want to migrate the backend database from MS Access 2000 to MS SQL Server 2000. However, I want to keep the MS Access 2000 interface. Would it be possible? If I migrate the MS Access to SQL Server, would the queries, back-end VBA, macro, tables and forms be affected? Do I need to change the MS Access data type to SQL server supported data type? Which tool I can use to do the migration? Upsizing wizard or exporting...

Should I upgrade from MS Access 97 to MS Access 2002
Hi guys My company has in one of their products used Access 97 and MS JET 3.5 for several years now. Should we move the database to Access 2002 -which we use now in other parts of the company and also upgrade the MS JET to the latest version? And what does MS JET do? Kjell Arne Johansen MS Jet is the database engine that comes with, and is, by default, used by Microsoft Access. If you aren't having any troubles with the Access 97 database, then there isn't any technical reason to change. There may be company political reasons if, say, the IT department only wants to have one ve...

How to set Data source in MS Word as MS Access Databases via DDE(*.mdb;*.mde).
How to set Data source in MS Word as MS Access Databases via DDE(*.mdb;*.mde). Everytime i click the command button to merge the data, it gives me item not found and i know that its a problem with my datasource. when i click ok then it opens the word doucment prompting me which datasource you want to use, when i click DDE then it gives me the merged data. Is there anyway i can set it permanantely in my codes below. Private Sub SetQuery(strQueryName As String, strSQL As String) On Error GoTo ErrorHandler 'set the query from which the merge ' document will pull its i...

Import MS Office Excel Comma Separated Values Files into a MS Access 2003 database
Hi, I have been tasked with Importing MS Office Excel Comma Separated Values Files into a MS Access 2003 database. These files were exported from a DB2 database.I have also been given the DDL code. I have Googled a solution to this task and have tried creating these tables using the DDL code in a query within a blank MS Access database. Is there a more expedient way to achieve this? I noticed, for example, that a field in DB2 has a data type of "decimal" while the same field would have the data type of "number". Thanks, Zuf What follows is the DDL: -------...

Importing MS Office Excel Comma Separated Values Files into a MS Access 2003 database
Hi, I have been tasked with Importing MS Office Excel Comma Separated Values Files into a MS Access 2003 database. These files were exported from a DB2 database.I have also been given the DDL code. I have Googled a solution to this task and have tried creating these tables using the DDL code in a query within a blank MS Access database. Is there a more expedient way to achieve this? I noticed, for example, that a field in DB2 has a data type of "decimal" while the same field in MS Access 2003 would have the data type of "number". Thanks, Zuf What follows i...

Ms Access frontend / Oracle backend problem
Hi all, I'm developing a database using Ms Access 97 as the frontend and Oracle 8.17 as the backend under win2k os. Using Oracle ODBC to link the tables in Ms Access. This database is supposed to be used by 10 users at anyone time. Everything else is working as I expected but one. The one problem is, everytime I update or insert records using SQL*Plus, the changes or the new records do not show when I open the linked table in Ms Access frontend. I had to restart my computer before the table in Ms Access showed the correct records/data. Has anyone else had the same problem? ...

Importing MS Access data into MS Word
In the thread "combining multiple address fields into 1 address field", Stuart (?) helped solve that problem. I then tried to set up a mail merge in Word to check how I could use and merge the data. I found the database tool bar and opened the appropriate database - but... I could not find a way to open a particular table or query in order to insert the fields from the query into Word. The procedure I followed was this: - open a blank word .doc - from the database tool bar selected "insert database" - a window opened, headed 'Database' and divided into 3 sec...

converting MS Word document to MS Access?
Hello-- I'm new here, and with using MS Access. I have a list of addresses that's now in MS Word, and it would be easier for me and the person I'm going to give this address list to, to be able to have the address list in MS Access. Is there a way to import these addresses into MS Access--and thereby not have to type them into the program--being able to do this would save a lot of time and work! Thanks in advance, Jean in VA Jean, that's sort of a loaded question. The whole thing entirely depends on how "normal" your address list is. In other words, is the f...

conversion of ms access 97 application to ms access 2000
hi access gurus would appreciate if u can give me pointers regarding conversion of ms access 97 application to ms access 2000, like what are the problems to be expected and how to handle it. also would appreciate if anyone can give pointers on using VSS with ms access 2000, how to handle multiuser issues when it comes to insert, update and delete. thanx in advance, regards bala balkiicbe@yahoo.com (bala) wrote in message news:<b62a781b.0310080544.6d2a08fc@posting.google.com>... > hi access gurus > > would appreciate if u can give me pointers regarding conversion of ms >...

Date picker from MS-Access 2000 to MS-Access 2003
Hello. How do I get a date picker (References: Microsoft Calendar Control 8.0 Location C:\Windows\System 32\mscal.ocx) inset in MS-Access 2000, to work in MS-Access 2003. TIA J�rn Why not scrap it and use the all-API approach Stephen Lebans has at http://www.lebans.com/monthcalendar.htm -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "JHB" <joern_bea@removeThis_tdcadsl.dk> wrote in message news:42190d18$0$48635$edfadb0f@dread15.news.tele.dk... > Hello. > > > > How do I get a date picker (References: Microsoft Cal...

Using VBA to toggle from MS Word to MS Access?
Access 2003, Windows XP SP2 I have an application that generates a word document populated with a variety of fields from Access tables. The word document is generated when the user presses a button (cmdGenerateAgreement) on a form (frmTransaction). I want the process to work as follows: 1. User presses button 2. Word document is opened and populated 3. Access screen becomes visible with a message box 4. User presses Ok 5. Word screen becomes visible for finalization My question is how do I achieve steps 3 and 5? I've tried SetFocus, Access Web's API: Manipulate Window (fSetAccessW...

Database connection to MS Access & MS Foxpro
Hi, When we select new project ,can "MFC AppWizard(exe)" make connection to database ? or only "database project" can make connection to database ? How do i make connection to database(MS Access/Foxpro) and perform sql using MFC Appwizard(exe) with ODBC --CDatabase? Any sample code ? Thanks. CBTan wrote: > Hi, > > When we select new project ,can "MFC AppWizard(exe)" make connection > to database ? or only "database project" can make connection to > database ? > > How do i make connection to database(MS Acce...

Use ASP to read MS Access query that calls MS Access function
Hi: I have an MS Access query for a table called MyTable. One of my fields in the query is a custom field that looks like "MyField: = MyFunction(ID)" where ID is a field in MyTable. I have ASP code and I can use it to read the query OK when "MyField" is not part of the query. If I add in MyField and then run my ASP code to try to read all the query fields, I get an error message on my web browser which says something to the effect of "cannot find MyFunction." On the Access side, I have MyFunction set up in a module and use the keyword "Public" in fr...

How to implement automatic procedures in MS Access to fill in MS Word document?
I have tblFiles with [FileID] and [FileName] fields. DLookUp("[FileName]","tblFiles","[FileID]=22") returns "c:\EMLfiles\00002.eml". The return string is a pointer to a dot-eml file in c:\EMLfiles. The dot-eml file was created in MS Outlook Express through its File - Save As facility. Each dot-eml file contains a small paragraph of text and a small (8k - 22k) graphic file. I'm seeking mechanism to read and interpret the dot-eml file and paste it into an open MS Word document. I really don't know where to begin. I know it is not as simple as op...

How to connect a remote MS Access/MS SQL Database from JSP on Linux?
I want to use JDBC to connect a remote MS Access/MS SQL database, however, I found that JDBC-ODBC is not support on remote database and Linux. I've visit the site of some middleware, like RmiJdbc, IDS,.... However, seems don't know how to make it functions and difficult to configure. Do anyone can give me a solution? Thanks Vincent ...

VBA in MS Word and MS Access different (use of external COM objects)
Hi, We have a COM object, which in turn use DDE to communicate with another application of ours. Access to this COM object works fine from C++, Visual Basic applications, VBS and VBA from MS Word. But the the same VBA code that works in Word fails in MS Access. Are there any differences in how VBA in MS Access use COM objects? Should a COM object be ceated in any special manner to be able to be used from MS Access? thanks/Patrik Sj�gren Most of the idiosyncrasies of the Access host container are documented via a couple of MS KB articles. Of the couple of ActiveX controls I have created ...

How to access data from an MS Excel sheet and import it to a MS Word using LabView?
Hello I would like to know how is it possible to access a specified data( for example row 1 ,column 2 to 5) in an Excel sheet and import it to a word document using LabView. Thanks You can interact with Office application through ActiveX, but you should be warned that it requires opening a lot of properties and going deep into the Office object hierarchy and this does not look nice in LabVIEW. If you open the example finder (Help&gt;&gt;Find Examples) and search for "ActiveX" or "Excel" you should find some examples on the basics of working with Excel. You can ...

how to export from ms access into ms excel?
I need to export to a particular excel worksheet, but I am unable to specify a range? Is there another way???? Please help...? Nettie ...

MS Access conversion to MS SQL
Hi, I've been developing a database for a department in a local organisation. The database is in Microsoft Access and uses tables, queries, forms and reports. Written into the forms is vast amounts of visual basic. There are also a couple of macros. In the time I've been developing this database (a year now, as I went back to university, and then finished university and returned to finish off the DB) the organisation I've been working for have decided to start using MS SQL. The department I am working for aren't to happy as not only my database but most of theirs are in Access...

Emailing Survey Through Lotus Notes (Surveys Generated in MS Access/MS Word)
I'm not sure if I have the right newsgroup, so please be kind. I have a MS Access database that generates surveys to send to employees. It creates the surveys based on a MS Word template. Each survey is saved as a separate MS Word doc. Instead of having the user copy and paste text from the MS Word doc to a new lotus notes email, I would like to send the surveys directly to Lotus Notes and save them as drafts. That way, the user could open the draft, ensure nothing's wrong, and then send it. I have the VB code to send a Lotus notes email and it works (no APIs). My que...

MATLAB command to access MS Access database
Hi! Is there a MATLAB command which gives access to a .mdb MS Access database or do I need a special driver? Thanks, Andree Hi Andree Ellert, you can use activeXcontrol to interact with MS-Access database. access = actxserver('Access.Application'); returns the handle for Access. set(access, 'Visible', 1); will show the opened Access window. use get(access) and set(access) commands to find the methods available to call. -Vadivelu M =========== http://www.mathworks.com/access/helpdesk/help/toolbox/database/datatool.shtml "Andree Ellert" <ellert@gmx.net////...

request for explanation on access an database in ms access
This is the code that I found on the internet for accessing an ms access database: import java.sql.*; class Test { public static void main(String[] args) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); // set this to a MS Access DB you have on your machine String filename = "d:/java/mdbTEST.mdb"; String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ="; database+= filename.trim() + ";DriverID=22;READONLY=true}"; // add on to the end ...

Web resources about - Inserting value from MS Word into MS Access - comp.databases.ms-access

Inserting Kate
jurvetson posted a photo: the speaking GPS avatar that we came to love.. more prep photos below... You can hear her voice in the video compilation ...

Inserting the Galaxy Note 5’s S Pen backwards can permanently damage the device
One of the features Samsung highlighted when it unveiled the Galaxy Note 5 was the device's new S Pen slot design. The Note 5 features a spring-loaded ...


Inserting Slavery Into The Climate Debate
Chris Hayes compares the fight against fossil fuels to the abolitionist movement. He states plainly that “there is absolutely no conceivable ...

Samsung smart TVs inserting ads into third-party apps
... playback have pissed off a number of consumers. People with smart TVs from Samsung have been complaining that the electronics maker is inserting ...

Inserting images into Gmail could be so much better
When Google first launched the new compact compose window in Gmail, many of you might have noticed something annoying about inserting images. ...

Gawker tells Steven Crowder to "stop whining, take your licks, and accept that getting hit in the face ...
"... in the middle of an argument between billionaire-funded know-nothing ideologues and people whose livelihoods and stability are being threatened ...

Gmail's New Interface for Inserting Photos
Gmail has a new interface for adding images to a message. When you click the "insert images" icon, Gmail now shows all the photos highlighted ...

Why Hollywood Is Inserting These Two Huge Chinese Actresses Into Its Summer Blockbusters
... It shows the enormous potential in China for distributors. We've previously discussed how Hollywood is starting to cater to China by inserting ...

Samsung SmartTVs are inserting ads into movies - Business Insider
Random Pepsi pop-up ads have been appearing when SmartTV users watch content through the device's third-party apps.

Resources last updated: 2/19/2016 1:33:14 AM