Solved

MS Access and VB Script

Posted on 2011-02-21
2
225 Views
Last Modified: 2012-08-13
Hi Experts,

I have an access database which has two tables “Current_Year” and “Prior_Year”.  I would want a vb code to help me split the table in various text files based on the account number at a selected or given location. So I would end up with two text files one for Current Year table and another for Prior year table and the files should be placed in a folder at the destination given with folder name as the account number.
Thanks a lot in advance.

Regards,
Sai
Test-.mdb
0
Comment
Question by:Saichand
2 Comments
 
LVL 84
ID: 34945978
Can you show what you've attempted so far?

You can "split" a table by using queries. For example:

SELECT * FROM YourTable WHERE Year(YourDateField) = 2010

To do this, Create a new query, select your Table, and add all the fields you need to show in the Text file. You'll need to add a Calculated column to your query as well. To do that, move to a blank "column" in the query grid, and enter this in the "Field" row:

MyYear: Year([YourDateField])

This will create a column named "MyYear". You can then set a criteria on that column:

=2010

This will filter all the data in that table for any value where Year of your Date field = 2010. Save that query, and use it below.

From there, you can use the builtin Export functions of Access to move the data to a Text file. In 2007/2010 you would select the External Data tab - Export group - Text files. This brings up a wizard you can use to export that data to a standard TXT file.
0
 
LVL 6

Accepted Solution

by:
TinTombStone earned 500 total points
ID: 34946247
I have modified Test.mdb to include a form that does what you asked
Give it a go, see what you think

Test-.mdb
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

708 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

15 Experts available now in Live!

Get 1:1 Help Now