Access - How to "show all records" after importing from a .csv?

Hi -

I've got a Form with a button that imports .csv files.  The Import command button runs a macro, and it works fine.  However, after it imports the file to the underlying table, the form does not refresh the record count.  For example, if I have 20 records before the import, it says 1 of 20 at the bottom of the form.  

After importing 65 records, it still shows 1 of 20.  Also, even though a GoToControl action was executed, the cursor is nowhere on the form.

Then I click on the first field in the Detail section, and (either) press F5 (or click on Refresh All on the Ribbon), the record counter reads 1 0f 85.

Any ideas on:

1) getting the cursor back on a control
2) forcing a "refresh" of the record count


I've tried a few different things, but nothing seems to work.

I'm running Access 2007 on Windows XP, FWIW.

Thanks - ub  
RobertAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

diazlunaCommented:
Add the following after the import:

Form.Requery()
Form.Refresh()

That'll do it.
0
RobertAuthor Commented:
diazluna,

Where do I put that in the Macro?  Sorry if I'm a bit obtuse on this, not used to jumping between Macro and VBA!

ub
0
diazlunaCommented:
You mentioned that you had a Form with a button that imports .csv files.  I am assuming you are calling your macro from here.  Step 2 run the 2 lines of code I gave you.
0
Newly released Acronis True Image 2019

In announcing the release of the 15th Anniversary Edition of Acronis True Image 2019, the company revealed that its artificial intelligence-based anti-ransomware technology – stopped more than 200,000 ransomware attacks on 150,000 customers last year.

RobertAuthor Commented:
I don't know how to use the syntax you gave me.  I used the actions:

Requery
RunCommand (Refresh)

That's great - but the cursor is off in Neverland - I have no idea where it is.

I added GoToControl (fieldname), but... no cursor, blinking, block, or otherwise.

0
diazlunaCommented:
Use SetFocus()
0
RobertAuthor Commented:
How do I do that in a ***macro***?  
0
diazlunaCommented:
RunCommand (Forms!Form.SetFocus)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jefftwilleyCommented:
if you go to design view of your form. Click on the Import button. Open the properties sheet for the button. Go to the Events tab. Select the On_Click event and open the code.

After the call to the Macro (in the code), you can place a me.requery there. You do not need to add it to the Macro itself.

J
0
RobertAuthor Commented:
The RunCommand action would not accept the argument.

Please see attached.  It's a Macro, it isn't code.

On-Click-to-Macro.JPG
On-Click-Macro.JPG
0
jefftwilleyCommented:
see that little ... button out to the right of the OnClick event option? Click on that

It will open the VBA window where you can add code.

J
0
RobertAuthor Commented:
I do see the [...] button.  But since I have a Macro, it only opens up the Macro.
0
jefftwilleyCommented:
inside the design view of the Macro, select Save AS from the menu.  Save your macro as code. Now when you click the ... it will open you up to the VBA window where you can do your requery.
J
0
RobertAuthor Commented:
So the Macro actions just don't work right?
0
jefftwilleyCommented:
I suppose we can try.

Before you try your requery step, insert a step to select the object

SelectObject "ype = Form, ObjectName = "FormName" InDatabaseWindow = No

J
0
RobertAuthor Commented:
I did, and it still did not return focus to the torm.  No cursor, no focus.  Pressing Enter, Tab, Esc does nothing.
0
RobertAuthor Commented:
So - any other suggestions?
0
diazlunaCommented:
No more without seeing the actual database.  You have to give me some credit for the Refresh issue. :)
0
RobertAuthor Commented:
diazluna,

You've got 250 pts coming at you.  

ub
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.