Problem with record source in subform

Joined
Jan 31, 2007
Messages
2
Reaction score
0
I have a subform set for continuous forms within an unlinked parent form. The parent form basically provides a clean view with buttons around the subform. The main function of these forms is to do an import of records from Excel into a temp table and then display the results of the import. However, I cannot get Access to requery the subform and display the imported records. I have tried requery, refresh, repaint on the subform and parent form, I have tried setting the recordsource of the subform, and added a requery after that didn't work, which still didn't work. I don't know what else to try!

It seems like a bug in Access. Here's what is wierder: If after my import, I click on the popup menu and select Remove Filter/Sort then the records suddenly show up. I've also tried calling the docmd.runcommand for that menu item in my code and that does nothing. I hope I've explained things well enough. Any ideas?
 
Joined
Jan 31, 2007
Messages
2
Reaction score
0
Wow, very bizarre. I have finally fixed this.

I created a new subform that is connected to my temp import table while the primary subform is connected to the table containing the fully imported records. The parent form opens with the primary subform displaying all records previously imported. When a user clicks import and selects their file, the file is imported into the temp table and I have the sourceobject changed to my temp subform. This allows the user to review the import and fix anything before committing the records.

Even changing the subform does not display the newly imported records. I don't know why but I found that if I stepped through the code the records would be displayed. So, to fix this I did the remove filter I discovered earlier and an idle function I found in Access help. This is the new code that displays the subform records correctly after my import. If I comment out the idle, the remove filter does nothing, and if I comment out the remove filter the idle doesn't force the records to display so nothing happens. I also found the a requery finally works after the idle.

Code:
    Me.sbfmName.SourceObject = "sbfmRenImport"
    DBEngine.Idle dbRefreshCache
    DoCmd.RunCommand acCmdRemoveFilterSort
Or
Code:
    Me.sbfmName.SourceObject = "sbfmRenImport"
    DBEngine.Idle dbRefreshCache
 Me.sbfmName.Form.Requery
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top