Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2009-07-16
18
Medium Priority
?
463 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 2000 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

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

609 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