Solved

Help with Recordsetclone and DAO.Recordset

Posted on 2004-08-26
6
348 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
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 85

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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 51

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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
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…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

623 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