Solved

Help with Recordsetclone and DAO.Recordset

Posted on 2004-08-26
6
315 Views
Last Modified: 2008-02-20
Hi there I use the following code to report via message box.

'begin here
Function getCardValuesTest()


Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
 
    rs.MoveFirst
   
Do While Not rs.EOF
   

MsgBox "Card: " & rs!CardID & vbNewLine & _
"Usage: " & rs!Usage & vbNewLine & _
"Description: " & rs!CardDes


       rs.MoveNext
                   
       Loop
       
    rs.Close
    Set rs = Nothing

End Function

'end here


The code runs well through the recordset that is diplayed on the form.  But if i change the last record on the form it does not display  the change in my message box and will still use the old info, only when I move the focus to a previous record and run the code again does it display the correct info. Is there a way of updating or requering the recordsetclone before i run the code.

Regards

fouche




0
Comment
Question by:fouchev
6 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 11901887
just do a

Me.requery after you change the record,

better post the codes you are using for this form
0
 
LVL 7

Expert Comment

by:SQL_Stu
ID: 11901895
As you have declared, Set rs = Me.RecordsetClone - this means that rs will contain a snapshot of your recordset AT THAT POINT IN TIME.

When will the getCardValuesTest function be called?
0
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 125 total points
ID: 11901957
Or force the dataset to save:

Function getCardValuesTest()
'/forces a save ...
If Me.Dirty Then Me.Dirty = False

Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 49

Expert Comment

by:Gustav Brock
ID: 11901971
Try inserting these few lines:

Dim rs As DAO.Recordset
If Me.Dirty = True Then
  ' Save current record.
  Me.Dirty = False
End If
Set rs = Me.RecordsetClone
 
/gustav
0
 
LVL 1

Author Comment

by:fouchev
ID: 11901982
At the moment i call the function via a cmd buttons click event.

If I can get it to report it correctly on my message box i can then continue with the rest of what i want to do.

the form is based on the following:

SELECT tblCards.CardID, tblCards.CardColourID, tblCards.CardTypeID, tblCards.InStock, tblCardType.Type, tblCardColour.Colour, [type] & " (" & [colour] & ")" AS CardDes, tblCards.Usage, tblCards.ColourPhoto FROM tblCardType INNER JOIN (tblCardColour INNER JOIN tblCards ON tblCardColour.CardColourID = tblCards.CardColourID) ON tblCardType.CardTypeID = tblCards.CardTypeID;

Regards


Fouche
0
 
LVL 1

Author Comment

by:fouchev
ID: 11902054
Thanks ALL for the prompt response...appreciated!!

Cactus Data,  you also had it correct, but I had to go with the first correct response of LSMConsulting who also provided the same scenario and worked.

Cheers all

have a lovely day.

Fouche
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now