Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Help with Recordsetclone and DAO.Recordset

Posted on 2004-08-26
6
Medium Priority
?
357 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 500 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

704 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