473,320 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

refresh a form

AccessIdiot
493 256MB
I am familiar with Me.Refresh but how do you target another form to be refreshed?

In other words, if I have a textbox on Customers that records the number of orders that CustomerX has, then I go into the Orders record and change the number of orders, I want to close the Orders form and see the update on the Customers form.

I tried in the on close event of the orders form

Forms!frm_Customers.Refresh but it didn't work. Do I need to target the control box? Or do something else?
Apr 30 '07 #1
15 61197
MSeda
159 Expert 100+
Try requery instead of refresh
Forms!frm_Customers.form.requery
Apr 30 '07 #2
ADezii
8,834 Expert 8TB
I am familiar with Me.Refresh but how do you target another form to be refreshed?

In other words, if I have a textbox on Customers that records the number of orders that CustomerX has, then I go into the Orders record and change the number of orders, I want to close the Orders form and see the update on the Customers form.

I tried in the on close event of the orders form

Forms!frm_Customers.Refresh but it didn't work. Do I need to target the control box? Or do something else?
How exactly does your Text Box on the Customers Table record the number of Orders that CustomerX has? Please post the code, or provide an explanation.
Apr 30 '07 #3
AccessIdiot
493 256MB
Okay it's actually an Entrainment form that can have many Specimens attached to it. The code on the control source of the textbox on the Entrainment form is:
Expand|Select|Wrap|Line Numbers
  1. =nz(DSum("SpecimenCount","tbl_Specimen_Entrainment","Entrainment_ID = " & [Entrainment_ID]),0)
I'm also passing Entrainment_ID as OpenArgs when the frm_Specimen_Entrainment form is opened to add or edit specimens. On opening it sets the openargs to the Entrainment_ID foreign key of the Specimen_Entrainment table.

I have tried requery in the past but it didn't work for me - refresh would be better.
Apr 30 '07 #4
Rabbit
12,516 Expert Mod 8TB
A requery retrieves the latest information on the table or query that the object is based on.

A refresh updates the current record to a multi-user environment.

So it looks like you want to update the combo box with the latest information in which case you must target the combo box itself with a requery.
Apr 30 '07 #5
ADezii
8,834 Expert 8TB
I am familiar with Me.Refresh but how do you target another form to be refreshed?

In other words, if I have a textbox on Customers that records the number of orders that CustomerX has, then I go into the Orders record and change the number of orders, I want to close the Orders form and see the update on the Customers form.

I tried in the on close event of the orders form

Forms!frm_Customers.Refresh but it didn't work. Do I need to target the control box? Or do something else?
The most practical way to achieve your desired result, have the Text Box on the Customers Form reflect the current count given specific criteria, is to 'Requery' your Customers Form on the AfterUpdate() Event of the Orders Form. Requerying this Form will re-evaluate the Control Source for the Text Box. Since you are executing this line of code from the Orders Form, you must use the fully qualified Path as in:
Expand|Select|Wrap|Line Numbers
  1. Forms!frmCustomers.Requery
Apr 30 '07 #6
AccessIdiot
493 256MB
That works perfectly, thank you. And thanks for the explaining the difference between Requery and Refresh!
May 1 '07 #7
Rabbit
12,516 Expert Mod 8TB
Not a problem.

I would have to say that over 80% of what I learned I learned from the help files.
Note that there are different sets of help files, one for Access and one for VBA. The VBA help files contains a lot of documentation on all the functions available to you. Just highlight the name of the function and hit f1 or search for it by typing in the key words.

I didn't know about the refresh or requery. I just highlighted each word in the VBA editor and pressed f1. From there I just followed the links within the help files located at the top and within the article.
May 1 '07 #8
AccessIdiot
493 256MB
Yes that's usually my first approach too. Sometimes I have trouble with pathways, and with when to use "." vs "!". I know there has been a lot of discussion about it but its not always intuitive.
May 1 '07 #9
NeoPa
32,556 Expert Mod 16PB
A requery retrieves the latest information on the table or query that the object is based on.

A refresh updates the current record to a multi-user environment.

So it looks like you want to update the combo box with the latest information in which case you must target the combo box itself with a requery.
I find a .Refresh will actually update the data within all the records of a query. What it does not do, that a .Requery does, is to add or remove records from the list.

Start with :
Expand|Select|Wrap|Line Numbers
  1. A   Apple
  2. B   Bread
  3. C   Cardboard
After adding
Expand|Select|Wrap|Line Numbers
  1. D   Dogfood
Deleting
Expand|Select|Wrap|Line Numbers
  1. A   Apple
changing C to Cupboard and doing a .Refresh, you end up with :
Expand|Select|Wrap|Line Numbers
  1. #Deleted #Deleted
  2. B        Bread
  3. C        Cupboard
It's only after a .Requery (which takes longer) that you get :
Expand|Select|Wrap|Line Numbers
  1. B   Bread
  2. C   Cupboard
  3. D   Dogfood
May 1 '07 #10
HI,

I've been having a similar issue with a ComboBox that is not being refreshed after adding a new value on another form. I've tried adding Requery in AfterUpdate, Form_Current, etc. to no avail.... The test form has the combobox and a command button.

Here's my test code:

Private Sub cmdAddCatgCd_Click()
On Error GoTo Err_cmdAddCatgCd_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "subfrmHierCatgCd"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdAddCatgCd_Click:
Exit Sub

Err_cmdAddCatgCd_Click:
MsgBox Err.Description
Resume Exit_cmdAddCatgCd_Click
End Sub

Private Sub Form_AfterUpdate()
Me.Combo21.Requery
End Sub

Private Sub Form_Current()
Me.Combo21.Requery
End Sub

cmdAddCatgCd_Click opens another form to maintain the code values that are populated in Combo21.

So far, the only way I've been able to get this to work is by adding a "Refresh" command button with the following code:

Private Sub Command25_Click()
On Error GoTo Err_Command25_Click

Me.Combo21.Requery

Exit_Command25_Click:
Exit Sub

Err_Command25_Click:
MsgBox Err.Description
Resume Exit_Command25_Click

End Sub

I'd prefer having the requery happen automatically.....

Thanks, Ed.
May 4 '07 #11
NeoPa
32,556 Expert Mod 16PB
Please do NOT hijack this thread for you question!
If you need to post a link with reference to this thread then please do that, but in your own thread.

MODERATOR.

PS. When you do decide to post your question properly, please refer first to POSTING GUIDELINES: Please read carefully before posting to a forum.
May 4 '07 #12
Please do NOT hijack this thread for you question!
If you need to post a link with reference to this thread then please do that, but in your own thread.

MODERATOR.

PS. When you do decide to post your question properly, please refer first to POSTING GUIDELINES: Please read carefully before posting to a forum.
First off, I'm new to forums in general and I have read the guidelines.

Second, I used this thread since it was similar to a problem that I was having, it was not a closed thread and based on the guidelines, that is what I thought I was supposed to do - to research what was on this site, etc. and reuse what I could to reduce the number of threads.

Third, I'd appreciate not being chastised for making a simple mistake and that you should be more considerate with your tone and response. A lot of us are new and to make statements like "hijack", "When you do decide to post your question properly" as if I've committed some sort of serious offense is inappropriate to me. We are all adults here.

From now on, I'll be sure to open a new thread each and every time I have a question, even if it relates to an open issue that may be similar to an issue I have a question with.

Ed.
May 7 '07 #13
NeoPa
32,556 Expert Mod 16PB
First off, I'm new to forums in general and I have read the guidelines.
I'm pleased to hear it. I hope that means you noticed the bit about posting any code in the tags provided. This makes it so much less of a struggle for our experts to understand your question (and incidentally saves me the time of going around afterwards adding the tags for you).
Second, I used this thread since it was similar to a problem that I was having, it was not a closed thread and based on the guidelines, that is what I thought I was supposed to do - to research what was on this site, etc. and reuse what I could to reduce the number of threads.
This is not inconsistent with with my suggestion of how to continue. I was merely making the point that diverting a thread from the original question is not allowed on this site - as per the guidelines. It's referred to as hijacking, and with a little thought, you will see why it causes confusion and makes life difficult for those who try to answer questions as well as those who are looking for answers later.
Third, I'd appreciate not being chastised for making a simple mistake and that you should be more considerate with your tone and response. A lot of us are new and to make statements like "hijack", "When you do decide to post your question properly" as if I've committed some sort of serious offense is inappropriate to me. We are all adults here.
I'm afraid my responsibility here is to the site and, though on a simple one to one basis I'd be more careful with my terminology, when communicating with someone with whom I've had no previous contact, I can only be brief and to the point. I'm afraid that there are far too many such posts that I have to deal with (in one form or another) to have the time to find out from you your understanding of the issue first.
From now on, I'll be sure to open a new thread each and every time I have a question, even if it relates to an open issue that may be similar to an issue I have a question with.

Ed.
I can't argue with that.
You sound like a sensible type of guy, and I'm sorry if my tone has offended you. I can't promise to react differently in future as I hope I've explained.
If you feel unhappy with this response, or even my initial one, please feel free to bring this up with another Access Moderator or Site Admin, who will be happy to respond to your PM.
As the site is having some problems at the moment they may not be listed so I can tell you that the Admins you'd need to PM are any of MMcCarthy, r035198x or Banfa.
May 7 '07 #14
Thanks for the clarification and subsequent explanations, I appreciate that.

Take care, Ed.

P.S. Me, sensible ? LOL
May 7 '07 #15
NeoPa
32,556 Expert Mod 16PB
Thanks for the clarification and subsequent explanations, I appreciate that.

Take care, Ed.

P.S. Me, sensible ? LOL
Not a problem.
We would like all our members to feel at home and helped here. I certainly did on my first visit.

Sensible? - I thought you expressed yourself well. That always helps.
Take care ;)
May 7 '07 #16

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Akinia | last post by:
Hi every body I've got a little problem with my form ("frm_Company"). It is divided in two parts: - first one is filled with some text fields over the company. - second one is filled with a tab...
1
by: Bill | last post by:
I have five users using the same forms to enter and retrieve data from an Access database held on a server but the only way each user can see any changes to records is by closing and reopening the...
1
by: jdph40 | last post by:
I have a form (frmEmpMaint)that can be opened from the switchboard and/or from a button on another form (frmVacations). frmVacations is based on a query where the criteria for employment status is...
3
by: Brian Basquille | last post by:
Hey there all, Fairly easy question for a C# expert, i assume! Am still working on my Photo Album. On frmBrowsePhotos, i have a listBox (photosList) containing photoID's from a table in an...
3
by: KayC | last post by:
Hi Background info: I am running Access 2000 I have a form bound to a blank table When a user clicks a button the form opens in datasheet view User enters data into form and closes form User...
0
by: M G Henry | last post by:
I am using Access 2003 and have a form with two subforms on them. I would like to be able to use a command button to add the row of data ( 5 fields ) that are completed on the subform, as well as...
5
by: Umoja | last post by:
Hi Guys, I need for one of my form to refresh after a selection is made from a combo box. On my main table I have a status field which the default value is set to ‘No’. Once the selection is made...
4
by: billa856 | last post by:
Hi, My project is in MS Access. In that I have one Form(DataEntry) which I am using for entering data into the Table(PRODUCTION). Now after entering data in Textboxes when I click on...
7
by: CF FAN | last post by:
need logic so when the page is refreshed that it returns to the location of the change, not to the top of the page. Currently, when the page is refreshed, it takes you back to the beginning of...
11
by: rajeevs | last post by:
Hi All I have two issues to put forward. First is bookmarking / or highlighting a particular record in a form. The form is continuous and the records are from a query result. One of the record...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.