Solved

What is the quickest/easiest way to test if a recordset has been updated, when it is bound to a datagrid.

Posted on 2002-04-10
8
144 Views
Last Modified: 2010-05-02
I have a datagrid that is bound to a recordset.

Before the user hits the save button and I do the updatebatch command on the recordset, they could hit the search button again and refresh the resultset!!!

To prevent this I want to issue an error message if the recordset has been updated but not saved when the search button is pressed.

What is the easiest and neatest way to do this ?

VB6 ADO recordset.
0
Comment
Question by:philhill
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 4

Accepted Solution

by:
RichW earned 50 total points
ID: 6930964
The easiest way is to set a variable as a flag when they first click the search button, and check for that value each time they click the search button.  If the value isn't what you want it to be then kick off a error message and turn off the sub with an Exit Sub.

Set a variable as a Long, and set it to zero (0).  Each time they go into the click event of the search button test for the variable to see if it's >0.  Inside the click event say variable = variable + 1.

This way they can only go into the click event once.

If the variable is >0 then give a msgbox and do a Exit Sub.

That's about the easiest way I can think of.

Hope that helps.
RichW


0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6931823
Search command moves the current record, ADO does an update every time you edit/add a record and you move to other one.
0
 
LVL 10

Expert Comment

by:arana
ID: 6931937
what about begintrans and committrans  ?

use commit only in save button , and on search button use
rollback
0
 

Author Comment

by:philhill
ID: 6933559
RichW got it half right.
I solved it on my own in the end by checking old and new
values every time the beforecolumn_update method is called
if there was a difference in any of the values I set a boolean flag (datagridupdated = True).  Then when clicking the search button checked this flag a gave a chance to save.  After the search button is clicked always reset the flag to False again.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Expert Comment

by:RichW
ID: 6933712
Thanks, but I would've preferred you gave it to someone else considering you gave me a C.

You changed the event from Click to Beforecolumn_Update, and you changed the type from Long to Boolean.  How is that getting it half right?

You asked for the easiest way to stop users from clicking search more than once, and I gave you an idea for a method to use.





0
 

Author Comment

by:philhill
ID: 6933769
Your answer would have been fine for a single data item in the datagrid, but when you have hundreds of rows and columns its not really practicle to save the values of each and compare them.

Anyway why are you complaining you got the points !!!
Get a life as well.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6933821
philhill, please, read guidelines regarding on how to grade an answer. Maybe this time it was not for an "A" but sure it wasn't for a "C". At least, RichW did puts you in right track.
Cheers
0
 
LVL 4

Expert Comment

by:RichW
ID: 6933926
Who told you to save the values of each??  I told you to set a variable flag for when you go in, and check the flag each time.  This is essentially what you're doing with the Boolean.  You're checking the flag each time you go in.

Thanks anyway, minus the smart-ass comments.

RichW
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

932 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

7 Experts available now in Live!

Get 1:1 Help Now