Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 05-28-2017, 10:24 PM   #1
shafara7
Newly Registered User
 
Join Date: May 2017
Posts: 118
Thanks: 23
Thanked 0 Times in 0 Posts
shafara7 is on a distinguished road
Button to refresh or reload form

I have a few comboboxes with filtering type and a subform and when I am done with my work, I want the form to be reset as if it is just loaded.
I want to have a refresh button on my form so that when I click it, it will return the form to it's original untouched form.

I tried adding a button and set the category to Form Operations and the Actions to Refresh Form Data. But it does not work. An error occured saying The Action 'Refresh' is not yet available.

Any idea why? Is there any VBA codes for this?

shafara7 is offline   Reply With Quote
Old 05-28-2017, 10:42 PM   #2
JHB
Have been here a while
 
Join Date: Jun 2012
Location: In the south of Denmark (Jutland), near the German border.
Posts: 7,428
Thanks: 2
Thanked 1,993 Times in 1,949 Posts
JHB has a spectacular aura about JHB has a spectacular aura about
Re: Button to refresh or reload form

You could try a requery.
Code:
Me.Requery
Else close the form and open it again using VBA code.
Code:
DoCmd.Close
DoCmd.OpenForm "YourFormName"
__________________
If the above post has helped you, why not take the time to say thank you, by pressing the "Thumbs up."
JHB is online now   Reply With Quote
Old 05-28-2017, 11:04 PM   #3
Cronk
Newly Registered User
 
Join Date: Jul 2013
Posts: 1,904
Thanks: 2
Thanked 410 Times in 403 Posts
Cronk will become famous soon enough
Re: Button to refresh or reload form

If the parent form is not bound to a data source and all that is required is to set unbound filtering combos backed to their "original untouched form" then on your button's code, for each filtering control put

me.MyCombo = [original value]
or if they are blank
me.MyCombo=null

Cronk is offline   Reply With Quote
Old 05-28-2017, 11:28 PM   #4
shafara7
Newly Registered User
 
Join Date: May 2017
Posts: 118
Thanks: 23
Thanked 0 Times in 0 Posts
shafara7 is on a distinguished road
Re: Button to refresh or reload form

JHB, I tried Me.Requery but nothing happend. Closing and opening it again is also not an option because that is what I have been doing before. That is why I need a button to simplify the work.

Cronk, I tried the me.MyCombo=null code, but it will only reset my combobox to Null, my subform and listbox is not reset back even though it is suppose to be controlled by that combobox.
shafara7 is offline   Reply With Quote
Old 05-29-2017, 02:56 AM   #5
isladogs
Part time moderator
 
isladogs's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 6,890
Thanks: 92
Thanked 1,694 Times in 1,572 Posts
isladogs is just really nice isladogs is just really nice isladogs is just really nice isladogs is just really nice isladogs is just really nice
Re: Button to refresh or reload form

Sometimes you do have to specify items separately e.g. use one or more of the following

Code:
'form/subform
Me.Requery
Me.subformName.Requery 

'combo boxes
Me.combobox1=""
Me.combobox2=""

'listboxes
Me.listbox = Null
Me.listbox.Requery

'multiselect listboxes
For Each varItem In Me.Listbox.ItemsSelected
        Me.Listbox.Items.Selected(varItem) = False
    Next varItem

'or ....
For I = 0 To Me.Listbox.ListCount - 1
        Me.Listbox..Selected(I) = False
Next
If all else fails then do close & reopen the form but use Application.Echo to stop screen updating until its complete

Code:
Application.Echo False
DoCmd.Close 
DoCmd.OpenForm "FormName"
Application.Echo True
That way you won't even notice the reloading & its quick

__________________
If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left.

Website links:
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.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Colin
Previously known as ridders : Access 2010 32-bit, Access 2016 32-bit & 64-bit, SQL Server Express 2014, Windows 10,
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.
isladogs is offline   Reply With Quote
The Following 2 Users Say Thank You to isladogs For This Useful Post:
opopanax666 (05-30-2018), psyc0tic1 (08-13-2018)
Reply

Tags
button , form button , refresh , reload

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA to refresh,reload,requery a report? MsLady Modules & VBA 10 04-05-2009 01:24 AM
Refresh form A from Command Button on form B aldeb Forms 2 02-07-2007 11:02 AM
can a refresh button on a form remove the current filter. antonyx Forms 1 03-05-2006 09:27 AM
Refresh Button and Importing Form sondriven Forms 3 05-23-2003 10:06 AM
Refresh/Reload Issue e2cheng Forms 2 01-09-2003 02:58 PM




All times are GMT -8. The time now is 11:03 PM.


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

Sponsored Links

How to advertise

Media Kit


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