Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 7th, 2005, 04:41 PM
Registered User
 
Join Date: Feb 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to set current recordset (rst.)

Hi,

I'm not very familiar with VB and ACCESS 2003, I have created a database with a field in wich I can load a binary file. After I've selected the file (browse) I have a button SAVE wich will get the file and save it in the field. The problem I have is:

if I'm using it I'm always updating the file from the 1st recordset. Even if I'm in the 3rd recordset, the file is applied to the 1st one.
So how can I specify to use the CURRENT RECORDSET.

My save button code is:

Private Sub cmdSave_Click()

On Error GoTo err

Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strFileName As String

    Set db = CurrentDb
    Set rst = db.OpenRecordset("tblData")
    'check a file path was entered
    If getFileName(txtPath.Value) <> "" Then 'see modGlobals for getFileName function
        'next check file exists
        If fileExists(txtPath.Value, getFileName(txtPath.Value)) Then 'see modGlobals for fikeExists function
            'THE SET CURRENT RECORD CODE GOES HERE ????
            'rst.AddNew 'prepare recordset for a new record
            If ReadBLOB(txtPath.Value, rst, "file") = 1 Then 'stores the binary data see modBlob for ReadBLOB function
                rst!filename = getFileName(txtPath.Value) 'store the filename
                rst.Update 'update the record
                MsgBox "Success!", vbInformation
            Else
                MsgBox "Failed!", vbExclamation
            End If
        Else
            MsgBox "Specified file does not exist!", vbExclamation
        End If
        rst.Close
        db.Close
    End If

 
Old February 11th, 2005, 11:42 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 100
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

If you got the readBLOB Routine of the MS site you should notice that the routine does not move throught the recordset, all it does is Edit the current record. Even though you are passing the recordset and it is on a new record the passing will not remember where the recordset position was and so when the readBLOB routine recieves the recordset it defaults back to the first record. Either pass a variable to the readBLOB routine to act as a bookmark or change the .edit to a .AddNew in the readBLOB routine.

hth

Jon





Similar Threads
Thread Thread Starter Forum Replies Last Post
Rst.BOF And Rst. EOF question jpaul VB Databases Basics 2 November 14th, 2007 05:56 PM
Current Recordset does not support updating. u813222 Classic ASP Professional 1 March 3rd, 2006 08:41 PM
Referencing a field from the current recordset PeterGonzales Access VBA 2 January 5th, 2006 01:45 AM
ADODB.Recordset (0x800A0CB3)Current Recordset does tks_muthu Classic ASP Databases 0 June 16th, 2005 07:22 AM
set record in the recordset to be unmodified benmics ADO.NET 0 August 23rd, 2004 11:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.