Solved

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

Posted on 2009-07-16
18
454 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
  • 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
 

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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now