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. 8 1645
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.
\__\
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
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.Connectio n
cn.open "connection string here"
cn.Execute "insert..."
cn.close
set cn=nothing
--
\\\\\\
\\ \\ Windows is searching
\ \ For your sig.
\ \ Please Wait.
\__\
"Trevor Best" <nospam@localho st> wrote in message
news:41******** *************** @auth.uk.news.e asynet.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.Connectio n cn.open "connection string here" cn.Execute "insert..." cn.close set cn=nothing
With ADO in A2000+,
Dim cnxn As ADODB.Connectio n
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
Darryl Kerkeslager wrote: With ADO in A2000+,
Dim cnxn As ADODB.Connectio n 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.
\__\ Darryl Kerkeslager wrote: Dim cnxn As ADODB.Connectio n 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@localho st> 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.Connectio n
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
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.
\__\
"Trevor Best" <nospam@localho st> 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... This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Tom Dauria |
last post by:
What I am trying to do is write a resume into a word document from
information in an Access database. I have been using bookmarks and
inserting table results into the document and so far it's working but
I have run into a problem.
The final section of the resume deals with Experience which is
subgrouped by Market Segments and then experience.
What I want it to look like is
|
by: sms1 |
last post by:
My Participants table in Access 2002 contains about 1500 records. The
Notes field is OLE. I want to use Insert Object to insert MS Word into
the Notes field. It is easily done using: Insert Object, etc.; no
problem for inserting one at a time. Problem: I don't want to go
through this same Insert Object procedure 1500 separate times. There
MUST be a way to do a "group" Insert Object in the Notes field so all
1500 are completed at once...
|
by: ajk |
last post by:
Hi, All:
I know how to insert files into a Word doc using C#. However, the program
I've written to do this runs much too slowly. The
"myObj".Application.Selection.InsertFile method executes at a snails pace.
Here are the detais:
I wrote a C# program that creates a new Word doc and then loops through a
list of HTML files to insert them into the new doc (sample code below). The
purpose of the program is to make one Word doc out of all...
|
by: ajk |
last post by:
.
Hi, All:
I know how to insert files into a Word doc using C#. However, the program
I've written to do this runs much too slowly. The
"myObj".Application.Selection.InsertFile method executes at a snails pace.
Here are the detais:
I wrote a C# program that creates a new Word doc and then loops through a
|
by: Flurry |
last post by:
Hello
I have a simple problem but I think the solution might be tricky...
I have a word document on the server which people can download.
However, what I would like is to use asp.net to insert a unique serial
number into the word document before it is downloaded. So I need some
way to insert a value into the word document. Is there a simple way of
doing this???
| |
by: santuvssantu |
last post by:
Hi Friends,
I have tried inserting an excel file to a word document.But the following code is inserting the junk information. So can you please help me out?
Dim m_WordApp As New Word.Application
Dim m_WordDoc As Word.Document
m_WordDoc = m_WordApp.Documents.Open(CObj("C:\Documents and Settings\santu\My Documents\New Microsoft Word Document.doc"), CObj(False), CObj(False), CObj(False))
|
by: Mike Fellows |
last post by:
I have some images stored locally that i retrieve and insert into a word
document that is programatically created
im using the following code
If File.Exists("C:\Pic2.jpg") Then
myWordDoc.ActiveDocument.Bookmarks("PHOTO2").Select()
myWordDoc.Selection.InlineShapes.AddPicture("C:\Pic2.jpg")
Else
myWordDoc.ActiveDocument.Bookmarks("PHOTO2").Select()
|
by: hakkatil |
last post by:
Hi to all,
I have a page that inserts excel sheet to access database. I am using asp. What I want to do is to check the inserting record if it is in the database. Basicly checking the dublicate record.
My code inserts records one by one using addnew-updatebatch. If there is a duplicate in the db, it will display "already exists" and if it is not in the db it will display "record added".
Below is my asp code I found on the net and...
|
by: rando1000 |
last post by:
Okay, here's my situation. I need to loop through a file, inserting records based on a number field (in order) and if the character in a certain field = "##", I need to insert a blank record.
So here's my method. I created two tables with the same structure as the table I'm inserting from. One table, Split_Temp, is the one I'll be inserting to. The other table, Split_Insert, contains the "Blank" record, which actually just has the word...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |