refreshing a query

tealeaf

Board Regular
Joined
May 15, 2002
Messages
160
Hi i already have a maketable query. what is the vba code for refreshing? the query uses the "NOW()" function, thus everytime i call the Sub i'd like to refresh the table.
thanx
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Correct Requery is calling the recordset Close method and then calling its open method again with the orginal data

you might also try "Resync: This resync'sx the records in your recordset with the underlyind database.

Hope this helps.

Let me know


Jack
 
Upvote 0
ok i'm really a beginner here. if i do want to use requery, how would i go about doing that?
say my queryname of the maketable query is "query1"
so far i have
dim rst as dao.recordset
set rst = currentdb.openrecordset("query1")

the second line of code produces an error. i tried it with another query, a regular query with no maketable, and it works. to use requery it should look something like
rst.requery right?
but to what do i set rst first?
 
Upvote 0
The best way to do a Requery is to write a Macro. Go to Macros and select Requery from the Action Drop Down Dialog box. Next enter the control you are attempting to requery and Select the Control to have the action take effect on.

You can also write VBA for the Requry as follows,

Sub RequeryList()
Dim ctlList As Control

' Return Control object pointing to list box.
Set ctlList = Forms!Employees!EmployeeList
' Requery source of data for list box.
ctlList.Requery
End Sub



Please let me know if this helps you.



Jack
 
Upvote 0
thanx jack
i'm not really sure if that will work given that i'm not working with "controls" but rather with a query i made. it's that query i want updated. is that possible? also i want to be able to update the query with an assigned date now. for example i want to be able to pass a date as an argument to this function, which will update the query.
but thanx so much for your suggestion
T
 
Upvote 0

Forum statistics

Threads
1,221,530
Messages
6,160,351
Members
451,639
Latest member
Kramb

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top