How To Use a Form To Specify Input And Output

P

Probie Coder

I have a task to read in a pipe delimited text file and output the same file
to a tab delimited file. I am to include a form to specify the input and
output and add a button on the form to run the conversion.. I cannot use any
macros to perform the conversion. (i.e. TransferText).

I am new to Access programming. Is there a way to accomplish this?

Thank you

- Thomas
 
R

Rick Brandt

I have a task to read in a pipe delimited text file and output the same
file to a tab delimited file. I am to include a form to specify the
input and output and add a button on the form to run the conversion.. I
cannot use any macros to perform the conversion. (i.e. TransferText).

I am new to Access programming. Is there a way to accomplish this?

Thank you

- Thomas

Are you only restricted against using "macros" or are you also not
allowed to use VBA code? I know of no way to do what you ask without
using one of those.
 
P

Probie Coder

Rick,

I can use VBA code; I cannot use macros i.e. "TransferText". I am new to
VBA coding and not sure how to do this.

Thank you!

- Thomas
 
R

Rick Brandt

Rick,

I can use VBA code; I cannot use macros i.e. "TransferText". I am new
to VBA coding and not sure how to do this.

But you see, there is a TransferText "action" that is used in macros and
also a TransferText "method" that is used in VBA code. So, is the
restriction that you can't use macros or that you can't use TransferText?

Basically you need to import the pipe-delimited data and export it as tab-
delimited data. There are probably a half-dozen ways to accomplish that,
but none I know of that wouldn't require macros or code.

Are you allowed to simply point and click in the user interface? If so...

File
- Get External Data
- Import

....then...

File
- Save/Export As
 
P

Probie Coder

Hi Rick,

Thank you for your quick responses.

My restriction is that I cannot use macros. I CAN do this task using VBA
code, so I can use the TransferText in VBA code. Not sure quite how do to
that, but I will try to investigate a little further.

I already did perform the operation by the example you provided below, but
that is not allowed:

File
- Get External Data
- Import

....then...

File
- Save/Export As

Any other advise you can provide would be greatly appreciated!

Thank you!

- Thomas
 
S

Stuart McCall

Probie Coder said:
I have a task to read in a pipe delimited text file and output the same
file
to a tab delimited file. I am to include a form to specify the input and
output and add a button on the form to run the conversion.. I cannot use
any
macros to perform the conversion. (i.e. TransferText).

I am new to Access programming. Is there a way to accomplish this?

Thank you

- Thomas

Place the following code in a standard module:

Public Function ConvertFile(inFile As String, outFile As String)
Dim f As Integer, b As String

f = FreeFile
Open inFile For Binary Access Read As f
b = Space(LOF(f))
Get #f, , b
Close f

b = Replace(b, "|", vbTab)

If Dir(outFile) <> "" Then Kill outFile
Open outFile For Binary Access Write As f
Put #f, , b
Close f
End Function

Then when you want to convert the file:

ConvertFile "C:\Temp\InputFile.txt", "C:\Temp\OutputFile.txt"

or, if you have the values in textboxes on your form:

ConvertFile Me.Text1, Me.Text2

(substitute your actual control names, of course)

The file "C:\Temp\OutputFile.txt" will be tab-delimited.
 
M

Mike Painter

Probie said:
Hi Rick,

Thank you for your quick responses.

My restriction is that I cannot use macros. I CAN do this task using
VBA code, so I can use the TransferText in VBA code. Not sure quite
how do to that, but I will try to investigate a little further.

If the same table is involved then import one by hand and click on
advanced. Save it and assign a name.
I think you can use the same information, change the delimiter and save it a
second time.
If not export it by hand and click on advanced...

Then it's
Run a delete query to empty the temp table
Docmd ... to import it
Doevents to be safe
Docmd.. to export it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top