Solved

MS Access and VB Script

Posted on 2011-02-21
2
267 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
[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
2 Comments
 
LVL 85
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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

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