Refresh Table After VBA Code

vahnx

Board Regular
Joined
Apr 10, 2011
Messages
188
I have a form with a button that inserts records into my table, but I must close and re-open the table to view the results. Is there some code or a way to make it auto-fresh the table?

http://youtu.be/lPxQmnI37SE
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Hi,

As a general rule I would suggest not viewing/working with tables directly. You can create a form that *looks* exactly like a table. You would do this by just using a form with the table as a data source -- display the form in datasheet view. The form's On Activate event can include the line me.refresh or me.requery. Even queries, if they are used to show data to users, are best implemented as forms in datasheet view, as you have much more options at your disposal for exercising control over the process.

Will that do the trick for you?

BTW, what technology do you use to create the youtube demo? I think one of my teachers used the same too.

ξ
 
Last edited:
Upvote 0
Thanks.

The software I used was 'Screencast-o-matic'. It runs from your browser using Java. For free use you get up to 15 minutes and a small watermark, and a built in uploader. It's great for quick tutorials.

CamStudio is a better solution for unlimited everything free, but not as convenient.
 
Upvote 0
Thanks - I might have a play with that some day.
To avoid unnecessary form refreshes, I'll revise my suggestion. Say you create a form called FormX based on your data table, putting it in datasheet view so it looks just like a table. You could then put in your button code:

Code:
Sub Command1_Click()
'//Do Update
Forms![FormX].Refresh
Or
Code:
Sub Command1_Click()
'//Do Update
Forms![FormX].Requery
 
Upvote 0
I would echo xenou's statements along the lines of not working in tables directly. If you use a form that is based on the table you can set it to be a datasheet view which looks like the table but also has events so you can do what you want to do. If you use the table directly you can not do what you are wanting.
 
Upvote 0
I am using xenou's solution :D I am just confirming Pretty1996's solution does not work. It would be nice though to view updated data directly.
 
Upvote 0

Forum statistics

Threads
1,221,821
Messages
6,162,157
Members
451,750
Latest member
pnkundalia

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