Solved

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

Posted on 2009-07-16
18
461 Views
Last Modified: 2013-11-28
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  
0
Comment
Question by:Robert
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 5
  • 4
18 Comments
 
LVL 2

Expert Comment

by:diazluna
ID: 24872835
Add the following after the import:

Form.Requery()
Form.Refresh()

That'll do it.
0
 

Author Comment

by:Robert
ID: 24873066
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
 
LVL 2

Expert Comment

by:diazluna
ID: 24873087
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Robert
ID: 24874068
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
 
LVL 2

Expert Comment

by:diazluna
ID: 24874289
Use SetFocus()
0
 

Author Comment

by:Robert
ID: 24874519
How do I do that in a ***macro***?  
0
 
LVL 2

Accepted Solution

by:
diazluna earned 500 total points
ID: 24878792
RunCommand (Forms!Form.SetFocus)
0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 24880242
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
 

Author Comment

by:Robert
ID: 24880973
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
 
LVL 34

Expert Comment

by:jefftwilley
ID: 24881020
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
 

Author Comment

by:Robert
ID: 24882613
I do see the [...] button.  But since I have a Macro, it only opens up the Macro.
0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 24886301
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
 

Author Comment

by:Robert
ID: 24890408
So the Macro actions just don't work right?
0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 24897222
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
 

Author Comment

by:Robert
ID: 24910639
I did, and it still did not return focus to the torm.  No cursor, no focus.  Pressing Enter, Tab, Esc does nothing.
0
 

Author Comment

by:Robert
ID: 24982425
So - any other suggestions?
0
 
LVL 2

Expert Comment

by:diazluna
ID: 24982506
No more without seeing the actual database.  You have to give me some credit for the Refresh issue. :)
0
 

Author Comment

by:Robert
ID: 24985192
diazluna,

You've got 250 pts coming at you.  

ub
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question