Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: How To Use a Form To Specify Input And Output

Geek News

How To Use a Form To Specify Input And Output
Probie Coder 12/22/2008 4:10:00 PM
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
Re: How To Use a Form To Specify Input And Output
Rick Brandt <rickbrandt2[ at ]hotmail.com> 12/22/2008 4:25:08 PM
On Mon, 22 Dec 2008 08:10:00 -0800, Probie Coder wrote:

[Quoted Text]
> 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.


--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Re: How To Use a Form To Specify Input And Output
Probie Coder 12/22/2008 4:43:03 PM
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

"Rick Brandt" wrote:

[Quoted Text]
> On Mon, 22 Dec 2008 08:10:00 -0800, Probie Coder wrote:
>
> > 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.
>
>
> --
> Rick Brandt, Microsoft Access MVP
> Email (as appropriate) to...
> RBrandt at Hunter dot com
>
Re: How To Use a Form To Specify Input And Output
Probie Coder 12/22/2008 5:18:04 PM
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


"Rick Brandt" wrote:

[Quoted Text]
> On Mon, 22 Dec 2008 08:43:03 -0800, Probie Coder wrote:
>
> > 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
>
> --
> Rick Brandt, Microsoft Access MVP
> Email (as appropriate) to...
> RBrandt at Hunter dot com
>
Re: How To Use a Form To Specify Input And Output
"Stuart McCall" <smccall[ at ]myunrealbox.com> 12/22/2008 6:06:56 PM
"Probie Coder" <ProbieCoder[ at ]discussions.microsoft.com> wrote in message
news:EDC0B128-DE0D-4F66-8E9F-10C35BE6469A[ at ]microsoft.com...
[Quoted Text]
>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.



Re: How To Use a Form To Specify Input And Output
"Mike Painter" <mddotpainter[ at ]sbcglobal.net> 12/23/2008 2:13:44 AM
Probie Coder wrote:
[Quoted Text]
> 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.


Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net