Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 12-04-2019, 11:45 AM   #1
PaulD2019
Newly Registered User
 
Join Date: Nov 2019
Posts: 15
Thanks: 12
Thanked 0 Times in 0 Posts
PaulD2019 is on a distinguished road
[SOLVED] Refreshing only certain fields on a form after a subform has been updated

Hi all,

I've been attempting to modify the database that was originally posted here

Code:
https://www.access-programmers.co.uk/forums/showthread.php?t=176891
Code is added so the main form refreshes after the reason box is changed after a date has been added, unfortunately when the main form refreshes it leaves the employee selected in the drop down box but the data in the subform refreshes to show employee 1's holiday data.

Is there a way to stop the subform data from changing or to set the refreshing code so only the data in the text boxes (Text35, Text37, Text61, Text65 & Text63) refresh?

A copy of the database is attached if someone can kindly have a look
Attached Files
File Type: accdb testing database.accdb (1.81 MB, 6 views)


Last edited by PaulD2019; 12-04-2019 at 01:02 PM.
PaulD2019 is offline   Reply With Quote
Old 12-04-2019, 11:52 AM   #2
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 6,486
Thanks: 58
Thanked 1,419 Times in 1,400 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: Refreshing only certain fields on a form after a subform has been updated

Hi Paul. Unfortunately, if you refresh or requery the main form, that also affects the subform because the main form controls what's displayed in the subform. What you can do is "remember" where you were before the refresh and then go back to it using code.
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is online now   Reply With Quote
The Following User Says Thank You to theDBguy For This Useful Post:
PaulD2019 (12-04-2019)
Old 12-04-2019, 11:57 AM   #3
PaulD2019
Newly Registered User
 
Join Date: Nov 2019
Posts: 15
Thanks: 12
Thanked 0 Times in 0 Posts
PaulD2019 is on a distinguished road
Re: Refreshing only certain fields on a form after a subform has been updated

Quote:
Originally Posted by theDBguy View Post
Hi Paul. Unfortunately, if you refresh or requery the main form, that also affects the subform because the main form controls what's displayed in the subform. What you can do is "remember" where you were before the refresh and then go back to it using code.
Thanks for the reply theDBguy, how would you make it remember with code?

PaulD2019 is offline   Reply With Quote
Old 12-04-2019, 12:14 PM   #4
moke123
Me.Dirty=True
 
moke123's Avatar
 
Join Date: Jan 2013
Location: Massachusetts
Posts: 784
Thanks: 3
Thanked 237 Times in 223 Posts
moke123 will become famous soon enough
Re: Refreshing only certain fields on a form after a subform has been updated

Those are calculated controls.

have you tried recalc method?
https://docs.microsoft.com/en-us/off...ss.form.recalc
moke123 is offline   Reply With Quote
The Following User Says Thank You to moke123 For This Useful Post:
PaulD2019 (12-04-2019)
Old 12-04-2019, 12:14 PM   #5
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 6,486
Thanks: 58
Thanked 1,419 Times in 1,400 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: Refreshing only certain fields on a form after a subform has been updated

Quote:
Originally Posted by PaulD2019 View Post
Thanks for the reply theDBguy, how would you make it remember with code?
Well, depending on what you're doing, I usually use the ID field for it. For example (pseudocode):
Code:
Dim lngID As Long
lngID = Me.ID
'refresh the form
'then
'navigate back to "[ID]=" & lngID
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is online now   Reply With Quote
The Following User Says Thank You to theDBguy For This Useful Post:
PaulD2019 (12-04-2019)
Old 12-04-2019, 12:26 PM   #6
PaulD2019
Newly Registered User
 
Join Date: Nov 2019
Posts: 15
Thanks: 12
Thanked 0 Times in 0 Posts
PaulD2019 is on a distinguished road
Re: Refreshing only certain fields on a form after a subform has been updated

Quote:
Originally Posted by moke123 View Post
Those are calculated controls.

have you tried recalc method?
https://docs.microsoft.com/en-us/off...ss.form.recalc
Thank you moke123, I haven't, I am still learning with access & I haven't ever used that before

Quote:
Originally Posted by theDBguy View Post
Well, depending on what you're doing, I usually use the ID field for it. For example (pseudocode):
Code:
Dim lngID As Long
lngID = Me.ID
'refresh the form
'then
'navigate back to "[ID]=" & lngID
There are ID fields on both the employee table (main form) & on the employee leave dates (subform). The text boxes on the main form count down how many "Paid Holiday" days & "Bank Holiday" days are left & count how many "Unpaid Days off", "Sick Days" & "No Show" days are recorded from the combo box on the subform.

I've got the below code on the after update event of the Reason field

Code:
Option Compare Database

Private Sub Reason_AfterUpdate()
Forms!Employees.Form.Requery
End Sub
Do I add your code into what I already have?
PaulD2019 is offline   Reply With Quote
Old 12-04-2019, 12:29 PM   #7
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 6,486
Thanks: 58
Thanked 1,419 Times in 1,400 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: Refreshing only certain fields on a form after a subform has been updated

Quote:
Originally Posted by PaulD2019 View Post
Do I add your code into what I already have?
Hi. Yes, you would. But before we go there, give Moke's suggestion a try first. Maybe it's all you need to do. Let us know how it goes...

__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is online now   Reply With Quote
The Following User Says Thank You to theDBguy For This Useful Post:
PaulD2019 (12-04-2019)
Old 12-04-2019, 12:41 PM   #8
PaulD2019
Newly Registered User
 
Join Date: Nov 2019
Posts: 15
Thanks: 12
Thanked 0 Times in 0 Posts
PaulD2019 is on a distinguished road
Re: Refreshing only certain fields on a form after a subform has been updated

Quote:
Originally Posted by theDBguy View Post
Hi. Yes, you would. But before we go there, give Moke's suggestion a try first. Maybe it's all you need to do. Let us know how it goes...
I replaced the refresh code with Recalc & it refreshes the text boxes

Thank you moke & theDBguy!!
PaulD2019 is offline   Reply With Quote
Old 12-04-2019, 12:42 PM   #9
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 6,486
Thanks: 58
Thanked 1,419 Times in 1,400 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: Refreshing only certain fields on a form after a subform has been updated

Quote:
Originally Posted by PaulD2019 View Post
I replaced the refresh code with Recalc & it refreshes the text boxes

Thank you moke & theDBguy!!
See. Good job! Nice work, Moke. Cheers!

__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is online now   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Update Parent form after subform updated? LucyF Forms 12 03-31-2015 04:35 AM
Refreshing fields in a form based on a ComboBox mba1942 Forms 2 07-17-2012 03:04 PM
Refreshing form after deleting from subform Matt Greatorex Forms 1 04-27-2006 06:34 AM
Form Subform refreshing j1nk5 General 3 09-10-2004 09:52 AM
Refreshing subform within form BigJimSlade Forms 6 10-13-2000 07:48 AM




All times are GMT -8. The time now is 05:32 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World