Requery Database

engelwood

Active Member
Joined
Oct 14, 2004
Messages
327
I've struggled several days with something that appears to be a straight foreword problem. I hope someone can help. I have a tab control with four different tabs. On one of those tabs I have a button that deletes the records of several tables. I would like to click over to one of the tabs and see the forms/reports updated. (Right now I'm just manually clicking refresh all to see the changes.) I have tried so many combinations of code (me.requery, etc...) and how to refresh (in the vba code, on current, etc...) that I'm finally throwing up the flag for help. And I can get anything to work. What an I doing wrong? Thanks in advance!
 
Last edited:

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Not sure I understand. You have forms and reports on a tab control and you want them to be updated when you activate the tab on your control? It's unusual to put a report on a tab control. You are not talking about the Tabbed View for forms/reports in the database window per chance?

The code to requery a form or report could go into an event associated with clicking the page of the tab control, but it would run each time regardless of whether or not any changes to the underlying data had been made. Instead, it should be part of the button click event that deletes the records. I would check first to ensure the object is loaded. IIRC, you cannot do this as written against a subform. Something like
Code:
If CurrentProject.Allforms("yourFormName").IsLoaded Then
  Forms!yourFormName.Requery
End If
 
Upvote 0
Not sure I understand. You have forms and reports on a tab control and you want them to be updated when you activate the tab on your control? It's unusual to put a report on a tab control. You are not talking about the Tabbed View for forms/reports in the database window per chance?

The code to requery a form or report could go into an event associated with clicking the page of the tab control, but it would run each time regardless of whether or not any changes to the underlying data had been made. Instead, it should be part of the button click event that deletes the records. I would check first to ensure the object is loaded. IIRC, you cannot do this as written against a subform. Something like
Code:
If CurrentProject.Allforms("yourFormName").IsLoaded Then
  Forms!yourFormName.Requery
End If

I do have a subform/subquery under a tab control. What I ended up doing was putting the subform requery action under the On Change event of the tab control. It works great! I thought I had unsuccessfully tried that earlier, but apparently I was wrong. Thanks for taking the time to respond!
 
Upvote 0

Forum statistics

Threads
1,213,561
Messages
6,114,315
Members
448,564
Latest member
ED38

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