Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Requery method

Status
Not open for further replies.

cavery

Technical User
Joined
Oct 29, 2002
Messages
129
Location
US
Hello all,
Currently I'm using shift <F9> to refresh my records, but I want to do this in code. I've used FormsRequery, but so far it doesnt requery. I've even used a Macro, that still doesnt work. Does anyone have any clue of how to code/use the Requery method? I only need it with one form, after I save and exit, I want the requery method to run. Any suggestions please?

Thanks,
Clark
 
Hi cavery,

try

Me.requery

&quot;so many events, so little time&quot;
 
Would this go in the after update event? or my existing
code? i.e.
Sub IdleTimeDetected(ExpiredMinutes)
DoCmd.Close acForm, &quot;fdlgTitleCommentHistory&quot;
DoCmd.Close acForm, &quot;frm_ExitNonUse&quot;
me.requery (?)
End Sub

Thanks,
Clark
 
If you are closing the form, you don't need to requery anything. The underlying source will automatically requery. Usually you requery when you want to update some information that the form needs immediately. What is your situation.

Paul
 
Thats the issue, I want to update immediately. Here is the issue:
I have unbound form, where users can update, save and then close the unbound form. After which they are directed back to the bound form (where the record resides). I want the bound form to update the records immediately after the user closes the unbound form. Instead of using shift f9. Hope I gave you a good idea of what I'm trying to do here....let me know..

Thanks,
Clark
 
In the Close event for the unbound form you could put
Forms!BoundFormName.Requery

That should do it or in the Got Focus event for the Bound form you could put
Me.Requery.


Paul
 
In some cases you use

SendKeys &quot;+{F9}&quot;

in code. This performs the <Shift> + <F9> automatically. &quot;It's got to be the going,
not the getting there that's good!&quot;
-Harry Chapin
 
Thanks Paul! I used the Forms!Boundformname.Requery and it works like a charm! I appreciate the help. Thanks for your feedback too Missingling. Have a good holiday.....

Clark
 
Well I've come across a rock in the road..

While testing on two computers, I've come across an error message: Run-time error 7878, Another user edited this record and saved the changes before you attempted to save your changes-re-edit the record.

I had two users attempt to save the same record just to see what message I would get....if any. Is there anyway to get around this? Funny thing is, this message doesnt appear everytime, there are times when its possible for 2 users to update and save the same record, but after the 3rd or 4th time it gives that message....

Any suggestions?
Thanks,
Clark
 
You can select from three different types of record locking in the Options box. Go to Tools....Options....Advanced tab and look at the different types available.

Paul
 
Here's my scenario. FormA has command buttons on it to go to FormB and FormC. FormA has 2 controls that refer to forms b and c. if it's not in the list of choices in the combo boxes they have to go to the forms b or c to edit, then come back to formA and choose the correct name from the list. I have it to where it is updating formA once a new record is entered into either B or C, the problem is that when I return to Form B/C and delete a record and return again to FormA, it doesn't clear the name from the choice box, nor does it give an error this time saying the person isn't there. Just doesn't show in the list, but the name stays. Also, just a side note, anyone know why if you click the access delete record button on the toolbar why the form numbers continue to increment in number? Kinda automatically adds a new blank record after deleting instead of going back to the last complete record.
TIA.

Angela
 
Angela, you can try this after you delete a name.
Me.ComboName.Requery. That should update the underlying recordset for the Combo box.

As for the record number, are you using AutoNumber?

Once you use a number with AutoNumber it won't reuse it unless you compact the database before trying to add another record.

Paul
 
Tried that, name leaves the list, but not in the text area where it was placed initially after choosing it from the list.

As for the record number, I can hit the delete record on the menu 10-20 times, it acts like you are still deleting records, yet all it's doing is adding another number and deleting, then adding another number. I have autonumber setup on other tables and don't get that problem. I just looked at another table where I delete the last blank record, doesn't add another record on top of it, whereas the main form does. Another thing is that with the scroll button on the mouse, if you roll it down, it will add record after record as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top