Here is the code that I copied and pasted from the internet, and I have been trying to modify it to fit what I am doing. The code is getting stuck on what seems to be pretty simple things (on the "Set conn = New DAO.Connection" ) with a message coming up saying "Complie error: User-defined type not defined". I'm sure there are going to be quite a few more compile errors after I get this one worked out as well. -
Private Sub Form_Open(Cancel As Integer)
-
'Sub Rst_Disconnected()
-
Dim conn As DAO.Connection
-
Dim myRecordset As DAO.Recordset
-
Dim strConn As String
-
Dim strSQL As String
-
Dim strRst As String
-
-
strSQL = "SELECT * FROM Clients"
-
-
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;"
-
strConn = strConn & "Data Source = " & "(database file-path)" & "\mydb.mdb"
-
-
Set conn = New DAO.Connection
-
conn.ConnectionString = strConn
-
conn.Open
-
-
Set myRecordset = New DAO.Recordset
-
Set myRecordset.ActiveConnection = conn
-
' retrieve the data
-
myRecordset.CursorLocation = callForm
-
myRecordset.LockType = adLockBatchOptimistic
-
myRecordset.CursorType = adOpenStatic
-
myRecordset.Open strSQL, , , , adCmdText
-
-
Set myRecordset = db.OpenRecordset("Clients", dbOpenDynaset)
-
-
Set myRecordset.ActiveConnection = Nothing
-
-
If Rs.RecordCount <> 0 Then
-
myRecordset.MoveFirst
-
Debug.Print myRecordset.Fields(0) & " was " & myRecordset.Fields(1) & " before."
-
'myRecordset.Fields("CustomerID").Value = "OCEAN"
-
myRecordset.Update
-
End If
-
-
strRst = myRecordset.GetString(adClipString, , ",")
-
Debug.Print strRst
-
End Sub
-
I hope this is enough for you all to work off of to help me, if you need anymore information, please let me know.
1 6773 ADezii 8,834
Recognized Expert Expert
DAO does not support Disconnect Recordsets, you must use ADO. I've posted the General Idea below: - Dim conn As ADODB.Connection
-
Dim myRecordset As ADODB.Recordset
-
Dim strConn As String
-
Dim strSQL As String
-
Dim strRst As String
-
-
strSQL = "SELECT * FROM Clients"
-
-
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;"
-
strConn = strConn & "Data Source = " & "(database file-path)" & "\mydb.mdb"
-
-
Set conn = New ADODB.Connection
-
conn.ConnectionString = strConn
-
conn.Open
-
-
Set myRecordset = New ADODB.Recordset
-
-
With myRecordset
-
.ActiveConnection = conn
-
.CursorLocation = adUseClient
-
.LockType = adLockBatchOptimistic
-
.CursorType = adOpenStatic
-
.Open strSQL, , , , adCmdText
-
End With
-
-
'Disconnect
-
Set conn = Nothing
-
-
'Modify Data, Recordset is disconnected but fully functional
-
-
'Reconnect using the Connection Object
-
-
'Update Source
-
rstDisconnect.UpdateBatch
-
-
'Check any changes made while disconnected
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Andie |
last post by:
Hello All,
How would I go about using a disconnect recordset and select (x) records
from it, x being the number of records to be selected.
Many thanks in advance.
--
Andie
|
by: Thomas Scheiderich |
last post by:
Why would you use the Recordset object over the Execute method of
getting data from your Sql database.
For example, I have the following:
Execute Method
***************************************************************
Set connectionToDatabase=Server.CreateObject("ADODB.Connection")
connectionToDatabase.ConnectionTimeout = 60
connectionToDatabase.Open "DSN=Customer;user id=SA;password="
|
by: Agoston Bejo |
last post by:
I would like to use an ADODB.RecordSet object to temporarily store some data
and then iterate through it. Actually it needs to be a RecordSet only
because it is a perfect choice as data structure for what I want to do, I
don't want to actually run queries or update tables with it.
It seems to me, however, that the RecordSet works only if there's a query
behind it. ADO complains about the RecordSet not being open when I try to
add rows by...
|
by: Mark |
last post by:
Hi - I have a recordset generated from a search between two dates - if
the user wishes to 'update' some of the records to show their interest
in some of the dates, is there a way I can just update the recordset,
and write it back to the database (used to use rs.Edit, rs.Update etc in
old ASP) - or do I still need to run an update query for the records I
want to update?
Thanks for any pointers,
*** Sent via Developersdex...
|
by: Steve Jorgensen |
last post by:
I keep having problems in which ADO disconnected recordset work under some
circumstances, but lose all their data at other times, having no rows or
fields, though the recordset object still exists.
One case where this happened to me today was in trying to store disconnected
recordsets in a cache collection in case they are needed again later in the
same session. When I retrieve the recordset from the collection, it's empty.
On the other...
| |
by: Liz Malcolm |
last post by:
Hello and TIA for guidance.
I am building a reusable search procedure (thanks go to Graham Thorpe
for his example that set me on my way). Everything works up until the
2nd match is found, the command doesn't go to the third match, it
exits out of the loop. I've read everything I could find in NG's, but
I can't figure out where I'm going wrong. Here is my code.
Function cmdSearch(ctlSearchText As Control, ctlFoundText As Control,...
|
by: Eric Peterson |
last post by:
I use the shape object to make recordsets that have no db
connection for use in grids and such. For example
(mPhoneNumbersRS as ADODB.Recordset)
****************************************
mPhoneNumbersRS.let_ActiveConnection
("Provider=MSDataShape;Data Provider=none;Data
Source=localhost;")
sTmp = "SHAPE APPEND NEW adChar(20) as Type, NEW advarChar
|
by: andy.mcvicker |
last post by:
Hi Gang
I have a large VB program that at one point does a lookup to a small
table (26 rows by 3 columns). With this table I have to do some
counting and retrieval of data. I'm finding that this slows the
program right down.
Is there any way I can take a copy of the table in memory and access it
there. Perhaps a cursor or something? Can someone help with a code
sample. Here's my code to do the lookup.
|
by: Arpan |
last post by:
Recently in an interview (for the post of ASP programmer), I was asked
"How do you define disconnected recordset in ASP". I was stumped &
couldn't answer. What's the answer to the question? Is it GetRows()?
Thanks,
Regards,
AD
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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: 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: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
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...
| |