Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing a record value temporarly 1

Status
Not open for further replies.

Scoty

Programmer
Oct 25, 2000
278
0
0
US
I am creating a datareport with a dynamic ado recordset as the source. What I would like to do is change the value of some of the field in a record with out actually committing the changes to the database? any idea's?

Please help.

Thanks
Scoty ::) "Learn from others' mistakes. You could not live long enough to make them all yourself."
-- Hyman George Rickover (1900-86),
 
Does the database you are using support "Rollback" ?

Example:

Dim wrkspace As Workspace
'Dim Database and Recordset

Set wrkspace = DBEngine.Workspaces(0)
'Set Database and Recordset
wrkspace.BeginTrans
'Edit and update recordset
If MsgBox("Save changes?", vbYesNo) = vbYes Then
wrkspace.CommitTrans
Else
wrkspace.Rollback
End If

If it is a multi-user database and If I remember correctly, All the records in the recordset (Possibly the table) are locked until the user commit to the transaction or rolls back.
 
it is an a97 database. So I'm not to sure if it has rollback cap. Besides I don't even want the changes going to the database at all. I am using it with an ODBC DSN connection across a network so the trafic at times can be pretty heavy. I just want to change the fields at run time so that I can get the information I need for the report. Thanks again
Scoty ::) "Learn from others' mistakes. You could not live long enough to make them all yourself."
-- Hyman George Rickover (1900-86),
 
With an ADO recordset you could try to append a new field to the adoRS and then find a way to pass the recordset to your report. Or use a disconnected adoRS for your application, this may be better.

' Dimension your Connection and Recordset

Dim adoConn as Adodb.Connection
Dim adoRS as Adodb.Recordset

' Create your connection

Set adoConn = new adodb.connection
with adoConn
.Provider = "Microsoft.Jet.OLEDB.3.51"
.ConnectionString = &quot;data source=<filepath to mdb>&quot;
.Mode=adModeRead
.Open
end with

' Create your recordset

set adoRS = new adodb.recordset
adoRS.CursorLocation = adUseClient
adoRs.Open &quot;<Table Name>&quot;, adoConn

' Kill any persisted dataset already out there.
' Sample: &quot;c:\access\saccess.dat&quot;

Kill &quot;<path to save recordset to>&quot;

' Save the recordset to a file.
' Sample: &quot;c:\access\saccess.dat&quot;

adoRS.Save &quot;<path to saved recordset>&quot;, adPersistADTG

' Now you have the recordset local and you can do with it
' what you wish.


' Open the saved recordset as a file

adoRS.Open &quot;<path to saved recordset>&quot;,,,adCmdFile

' What you do next is up to you.
' Modify your data, load into a flexgrid, etc...

' If you happened to want to return the changes to the
' original database you could use adoRS.UpdateBatch command
' You will need to look that up yourself though.
 
UPDATE:
What I ended up doing was making a database on the users local drive. I extract the information from the network database. and write the information to the database stored on the users local drive and pull the reports from there. Thanks for the hint BigDaddy

Here's your star &quot;Learn from others' mistakes. You could not live long enough to make them all yourself.&quot;
-- Hyman George Rickover (1900-86),
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top