Solved

Help with Recordsetclone and DAO.Recordset

Posted on 2004-08-26
6
304 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

759 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

24 Experts available now in Live!

Get 1:1 Help Now