X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Me.Refresh vs Me.Requery, Office 2002    
 
   
Enzyme80
post Apr 21 2010, 09:48 AM
Post #1

UtterAccess Addict
Posts: 299



I am dealing with some legacy code (possibly dated back to Access 2.0). It is now in Access 2002.
open a form, edit just one field on the form (the cursor is still in that field), then i close the form. This triggers different events and will save the record (all done with code). Here is my problem, if i only edit one field and do not tab to another field the only way I can get my record to update properly is to use a me.refresh or a me.requery before I do the update. Until yesterday we used me.refresh and this seemed to work and never really thought about it until I had a customer with 60,000 + records in the table and the me.refresh was taking about 8-10 seconds. I switched this to me.requery (for no other reason than to try it) and it did exactly what I need and did it quickly.
Now, from what I have read the Me.requery losses the current record and goes to the first one. Now, i have everything index so this is not a huge problem as i can just bookmark and go back as needed but my thought is that maybe this code is just wrong.
Should I have to do a me.refresh or a me.requery to know if the last field I am on has text entered or changed? My forms are not bound, everything is done through code and it works fine as long as i do one of those two functions. The other thing i can do is move the cursor to another field and then running the code without the me.refresh or me.requery will work.
Oreally hope that this makes sense to someone, I searched the forum and have been using google all week with no luck. I have found the "differences" between the two functions but I am not using them to update a record or to actually requery the data, I just want the textbox on my screen to know that it has been updated.
Thanks
Enzyme
Go to the top of the page
 
+
ace
post Apr 21 2010, 10:23 AM
Post #2

UtterAccess VIP
Posts: 5,422
From: Upstate NY, USA



Since your form is not bound to a recordsource Refresh and Requery have nothing to refresh or requery.
It seems strange that using either would affect how quickly a record is saved using code.
lso, bound or unbound, the value of a textbox is updated when focus leaves the control. So even
just clicking the built in close button should update the textbox.
How are you closing the form? Using a label for a button is the only way that comes to mind that would
cause the textbox control to not update. Labels do not receive focus.
Go to the top of the page
 
+
Enzyme80
post Apr 21 2010, 10:33 AM
Post #3

UtterAccess Addict
Posts: 299



It is actually an image but it does not receive focus as well.
Without using refresh or requery is there a way to "refresh" the screen to update the textbox, or would i have to set focus to another control first and then run the rest of the code?
Go to the top of the page
 
+
ace
post Apr 21 2010, 10:37 AM
Post #4

UtterAccess VIP
Posts: 5,422
From: Upstate NY, USA



You can set focus to some control in the click event of the image control.
generally use a textbox named txtSetFocus with a height and width of 0 so it is not visible
yet still receives focus.
Go to the top of the page
 
+
Enzyme80
post Apr 21 2010, 10:42 AM
Post #5

UtterAccess Addict
Posts: 299



I think that might be the best way to deal with it.
Is there any reason you can think of that would make me.refresh slower than me.requery? i am not talking like by a second, this is like 8-10 seconds for one and less than 1 second for the other.
Go to the top of the page
 
+
ace
post Apr 21 2010, 10:52 AM
Post #6

UtterAccess VIP
Posts: 5,422
From: Upstate NY, USA



I can't think of any reason to use either on an unbound form.
Go to the top of the page
 
+
Enzyme80
post Apr 21 2010, 10:55 AM
Post #7

UtterAccess Addict
Posts: 299



Thanks for the help!
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Search  ·  Go to Top  ·  Lo-Fi Version Time is now: 22nd December 2014 - 02:02 AM