Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 9th, 2005, 05:57 PM
Authorized User
 
Join Date: Sep 2004
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Kevin,
Thanks alot. Unfortunately, it tells me that the "File is already Open" and exits without even processing the SQL. I'll continue to research it and see if I can come up with something.
Thanks for all your efforts, I appreciate it.

Tim

 
Old February 9th, 2005, 06:04 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Tim,
Does your form, in the on_open process, use the opentextfile commmand?
If it does, turn it off, then try again.

Kevin

 
Old February 10th, 2005, 02:34 PM
Authorized User
 
Join Date: Sep 2004
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Kevin,
I'm not at work today but here is the situation: I get the error message "File is already open" when I run the code the second time. The form doesn't automatically open the document and I can't see it either, although it is "open".
Also, the SQL statement cannot understand the field "text line". I don't have the database here with me but I think your code is close to doing the trick. If I can solve the SQL part, it should work fine.
Thanks for all your help

Tim

 
Old February 10th, 2005, 04:36 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Tim,
Do you have a column in your table called text line? In my sample code, the table name is "Text Table", the Column is "Text Line". You need to rename these to match your table and column. Your variable to load each line is "textline".

Try that and let me know.

Kevin

 
Old February 11th, 2005, 11:33 AM
Authorized User
 
Join Date: Sep 2004
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Kevin,
I am getting a "syntax error in INSERT STATEMENT".
Here is the actual VBA that I am using:
Dim TextLine
Dim strquote As String
strquote = """"

Open "M:\3780\CorpActions\corp_pfd_namr.cax.2005013 1" For Input As #1
DoCmd.SetWarnings False
Do While Not EOF(1)
    Line Input #1, TextLine
    SQL = "INSERT INTO [tbl_corp_pfd_namr] ([CPN_Field1])," _
        & " SELECT " & strquote & TextLine & strquote & _
        " As Expr1:"
        Do.Cmd.RunSql SQL
Loop
Close #1


The SQL statement reads the "SELECT" part as SELECT Start-of-File....

Tim
 
Old February 11th, 2005, 01:30 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Tim,
The last statement of your sql - "As Expr1:' is wrong.
It should be - " As Expr1;"

Hope it works, let me know.

Kevin

 
Old February 11th, 2005, 01:45 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Tim,
There should also be no comma after ([CPN_Field1)" .
Cut and paste this in:

SQL = "INSERT INTO [tbl_corp_pfd_namr] ([CPN_Field1])" _
        & " SELECT " & strquote & TextLine & strquote & _
        " As Expr1;"
        Do.Cmd.RunSql SQL


Let me know!

Kevin

 
Old February 11th, 2005, 01:55 PM
Authorized User
 
Join Date: Sep 2004
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Kevin,
I get the message "Enter Paramter Value"
                   START

Could be getting there!

 
Old February 11th, 2005, 02:36 PM
Authorized User
 
Join Date: Sep 2004
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Kevin,
I'm getting the code to work now (I had changed the strquote earlier but changed it back to your specification). However, there are three outstanding issues:
1. I get this message when Access encounters the first row with more than 4 columns:
    Syntax error (missing operator) in query expression "264399BB1 corp100481117...the rest of the problem record
The first row is only 4 columns which sets the trend for the import.
2.When I click "O.K", I get a myriad of messages that say "Type Mismatch"
3. It still tells me that "The File is already Open" when I try to do it a second time!
Thanks again for all your input and expertise
Tim

 
Old February 11th, 2005, 02:38 PM
Authorized User
 
Join Date: Sep 2004
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I also for got to say that it imports the four columns to the first field only. I will try to insert other fields to the SQL statement.
Tim






Similar Threads
Thread Thread Starter Forum Replies Last Post
Encryption Notepad, need some help! Groogy Visual C++ 2005 0 March 23rd, 2007 12:31 PM
Automate import (fixed width) U.N.C.L.E. Access VBA 0 February 3rd, 2006 06:55 PM
Notepad or VS,Net Oh_Help VS.NET 2002/2003 2 February 11th, 2004 01:59 AM
Reference in notepad???? quetzalcoatl ADO.NET 2 October 31st, 2003 06:54 PM
Newline in notepad, HOW.....???? veskoula XSLT 3 October 29th, 2003 10:49 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.