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

 
Reply
 
Thread Tools Rating: Thread Rating: 12 votes, 5.00 average. Display Modes
Old 10-26-2006, 08:02 AM   #1
MsLady
Traumatized by Access
 
MsLady's Avatar
 
Join Date: Jun 2004
Location: Lagos <--> NYC
Posts: 438
Thanks: 0
Thanked 3 Times in 3 Posts
MsLady is on a distinguished road
Question VBA to refresh,reload,requery a report?

How do you refresh,reload,requery a report?
My report opens from a buttonclick on a form based on criteria on that form.

When i click to open the report multiple times and in each time changing the criteria on the phone, it doesn't refresh the report to the newly specified criteria. It still opens the report based on the very first selected criteria.
With a form it's just me.requery
How do you do this?

__________________

|The Stalk List - MsLady's Most Wanted|
Rural Guy - my vba hero. wanna be like you when i um grow up
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Pat Hartman - great one. my jewel of inestimate value
GMLWorldChamp! - My champ. you are amazing
ghudson - allow me to stalk you

|The Golden List - MsLady's Appreciation|
Kempes . CEH . Banana . ejstfl . OldSoftBoss . pbaldy . gemma-the-husky
MsLady is offline   Reply With Quote
Old 10-26-2006, 08:37 AM   #2
Jacob Mathai
Newly Registered User
 
Join Date: Sep 2001
Location: Rockville, MD, USA
Posts: 546
Thanks: 0
Thanked 5 Times in 5 Posts
Jacob Mathai is on a distinguished road
try this:

DoCmd.Requery
Me.Refresh
Jacob Mathai is offline   Reply With Quote
Old 10-26-2006, 08:52 AM   #3
MsLady
Traumatized by Access
 
MsLady's Avatar
 
Join Date: Jun 2004
Location: Lagos <--> NYC
Posts: 438
Thanks: 0
Thanked 3 Times in 3 Posts
MsLady is on a distinguished road
Quote:
Originally Posted by Jacob Mathai
try this:

DoCmd.Requery Command isn't available right now
Me.Refresh
Hi Jacob
I get errors on both lines.

DoCmd.Requery Command isn't available right now

Me.Refresh Data member not found

__________________

|The Stalk List - MsLady's Most Wanted|
Rural Guy - my vba hero. wanna be like you when i um grow up
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Pat Hartman - great one. my jewel of inestimate value
GMLWorldChamp! - My champ. you are amazing
ghudson - allow me to stalk you

|The Golden List - MsLady's Appreciation|
Kempes . CEH . Banana . ejstfl . OldSoftBoss . pbaldy . gemma-the-husky
MsLady is offline   Reply With Quote
Old 10-26-2006, 08:57 AM   #4
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 33,383
Thanks: 13
Thanked 4,122 Times in 4,054 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
You can't requery a report. You have to close and reopen it.
__________________
Paul
Microsoft Access MVP 2007-2019

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
Old 10-26-2006, 09:09 AM   #5
Jacob Mathai
Newly Registered User
 
Join Date: Sep 2001
Location: Rockville, MD, USA
Posts: 546
Thanks: 0
Thanked 5 Times in 5 Posts
Jacob Mathai is on a distinguished road
[QUOTE=MsLady]Hi Jacob
I get errors on both lines.

DoCmd.Requery
Me.Refresh

Did you put in the VBA code behind the command button that creates the report?
Jacob Mathai is offline   Reply With Quote
Old 10-26-2006, 09:31 AM   #6
MsLady
Traumatized by Access
 
MsLady's Avatar
 
Join Date: Jun 2004
Location: Lagos <--> NYC
Posts: 438
Thanks: 0
Thanked 3 Times in 3 Posts
MsLady is on a distinguished road
Quote:
Originally Posted by pbaldy
You can't requery a report. You have to close and reopen it.
But that's jsut what i am doing. when it reopens. it doesn't refresh the parameters received in the underlying query
__________________

|The Stalk List - MsLady's Most Wanted|
Rural Guy - my vba hero. wanna be like you when i um grow up
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Pat Hartman - great one. my jewel of inestimate value
GMLWorldChamp! - My champ. you are amazing
ghudson - allow me to stalk you

|The Golden List - MsLady's Appreciation|
Kempes . CEH . Banana . ejstfl . OldSoftBoss . pbaldy . gemma-the-husky
MsLady is offline   Reply With Quote
Old 10-26-2006, 09:31 AM   #7
MsLady
Traumatized by Access
 
MsLady's Avatar
 
Join Date: Jun 2004
Location: Lagos <--> NYC
Posts: 438
Thanks: 0
Thanked 3 Times in 3 Posts
MsLady is on a distinguished road
[QUOTE=Jacob Mathai]
Quote:
Originally Posted by MsLady
Hi Jacob
I get errors on both lines.

DoCmd.Requery
Me.Refresh

Did you put in the VBA code behind the command button that creates the report?
Yes. no luck

__________________

|The Stalk List - MsLady's Most Wanted|
Rural Guy - my vba hero. wanna be like you when i um grow up
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Pat Hartman - great one. my jewel of inestimate value
GMLWorldChamp! - My champ. you are amazing
ghudson - allow me to stalk you

|The Golden List - MsLady's Appreciation|
Kempes . CEH . Banana . ejstfl . OldSoftBoss . pbaldy . gemma-the-husky
MsLady is offline   Reply With Quote
Old 10-26-2006, 11:21 PM   #8
Kempes
Registered User
 
Join Date: Oct 2004
Posts: 327
Thanks: 0
Thanked 0 Times in 0 Posts
Kempes is on a distinguished road
it sounds like you need to save the changes to the table before refreshing the report.
Try this in the code that launches the report.

DoCmd.RunCommand acCmdSaveRecord
Docmd.requery
me.refresh

Hope it helps

Kempes
Kempes is offline   Reply With Quote
Old 10-27-2006, 12:12 AM   #9
gemma-the-husky
Super Moderator
 
gemma-the-husky's Avatar
 
Join Date: Sep 2006
Location: UK
Posts: 13,823
Thanks: 56
Thanked 1,030 Times in 996 Posts
gemma-the-husky is a name known to all gemma-the-husky is a name known to all gemma-the-husky is a name known to all gemma-the-husky is a name known to all gemma-the-husky is a name known to all gemma-the-husky is a name known to all
if you are just closing the report and then reopening it, when are you changing the parameters that would affect the report. It seems that that is the problem - the base query isn't changing.

If you are testing, instead of opening the report just put

msgbox(dcount("*","myquery")) which will report how many records in the query instead of opening the report, until you work out why the base query isnt changing.
gemma-the-husky is offline   Reply With Quote
Old 10-27-2006, 06:24 AM   #10
MsLady
Traumatized by Access
 
MsLady's Avatar
 
Join Date: Jun 2004
Location: Lagos <--> NYC
Posts: 438
Thanks: 0
Thanked 3 Times in 3 Posts
MsLady is on a distinguished road
hiyaaaa!!

I got it to work.

I found the problem was with my reset button. i placed a button on the form, that resets all the values on the form that takes parameters for my report query. When i click that button:
It resets the value of my combobox, Me![cboDept] = "" and i have an afterupdate event on this combobox to update an invisible textbox with the deptId of the value in cboDept, so putting "" was an issue, as there is no deptId associated with "". When i changed it to Me![cboDept] = Null. It works perfectly!

So as gemma suggested, I placed MsgBox (DCount("*", "qryAttendanceRecords")) in the code that opens the report/query to research and found it...

Thanks gemma-the-husky
Thanks Kempes
__________________

|The Stalk List - MsLady's Most Wanted|
Rural Guy - my vba hero. wanna be like you when i um grow up
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Pat Hartman - great one. my jewel of inestimate value
GMLWorldChamp! - My champ. you are amazing
ghudson - allow me to stalk you

|The Golden List - MsLady's Appreciation|
Kempes . CEH . Banana . ejstfl . OldSoftBoss . pbaldy . gemma-the-husky
MsLady is offline   Reply With Quote
Old 04-05-2009, 01:24 AM   #11
codywohlers
Newly Registered User
 
Join Date: Apr 2009
Location: Canada
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
codywohlers is on a distinguished road
Re: VBA to refresh,reload,requery a report?

Quote:
Originally Posted by Jacob Mathai View Post
try this:

DoCmd.Requery
Me.Refresh
That worked perfectly for refreshing my treeview inside my form. Thanks!

codywohlers is offline   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
Use VBA to CREATE a report modest Reports 24 03-15-2012 12:45 AM
open and filter report from vba Mr.K Modules & VBA 2 10-25-2006 04:12 PM
Combo Box Preview Report Mike Hughes Reports 10 03-10-2004 10:04 AM
Help linking VBA to a report keving Modules & VBA 2 03-07-2003 06:44 AM




All times are GMT -8. The time now is 01:08 AM.


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