Using VB5 to import data to access without using the Data control 
Author Message
 Using VB5 to import data to access without using the Data control

 I need to import a comma delimited data file to Access without using the
data control. I want to put the code in a .bas file (sub main) and have it
run without a user interface. I have some examples but need some more if
anyone has some. I also need the code not allow duplicate entries to the
database. Any help would be appreciated. Thanks, MikeMcclure.



Tue, 01 Feb 2000 03:00:00 GMT  
 Using VB5 to import data to access without using the Data control

Hello Michael,

In the latest issue of Visual Basic Programmer's Journal (Vol. 7, No 10,
September 1997) there is a great article on how to use the ASCII ISAM driver
to do this import for you.  Very cool stuff.  I'm not sure if the issue has
hit the stands yet, but if you are a member of the Premier Club, you can
download the article in PDF format and read it right now.  Jump out to
http://www.windx.com for a look-see.

I hope this helps,

--

Larry R. Tubbs Jr., MCPS, MCSD
Silverleaf Resorts Inc, NYSE: SVR

http://www.geocities.com/ResearchTriangle/5727/


Quote:
> I need to import a comma delimited data file to Access without using the
>data control. I want to put the code in a .bas file (sub main) and have it
>run without a user interface. I have some examples but need some more if
>anyone has some. I also need the code not allow duplicate entries to the
>database. Any help would be appreciated. Thanks, MikeMcclure.



Fri, 04 Feb 2000 03:00:00 GMT  
 Using VB5 to import data to access without using the Data control

Quote:

>  I need to import a comma delimited data file to Access without using the
> data control. I want to put the code in a .bas file (sub main) and have it
> run without a user interface. I have some examples but need some more if
> anyone has some. I also need the code not allow duplicate entries to the
> database. Any help would be appreciated. Thanks, MikeMcclure.

option explicit
dim field1 as string
dim field2 as string

< open necessary databases and recordsets to receive
  input>
open "f:\xx\<asciifilename> for outPut as #1
do until eof(1)
Line Input #1, nextline

field1 = mid(nextline,1,5)
field2 = mid(nextline,6,12)
etc

 'write sub routine to insert new data
loop
msgbox "End of File"
close

sub writerec
sub varreset  < write a sub so that the variables are reinitialized to "
" -- necessary if variables are public - you could pass then in an
array>
with <receiving recordset>
 .addnew
somethingRS!firstfield = field1
somethingRS!secondfield = field2
< etc etc>

 .update
end with

end sub

this is from memory Not having the manuals in hand I may not have the
syntax exactly
right but essentialy

- create a database to receive the data
- open the ascii file with Line Input - example in VB% language guide
- parse out the line to variables
-read variables into fields
- repeat

I have done at least fifty of these in the past few months - gets more
tricky when the various input files are not the same and the data has to
be parsed to fit a standard format

I think Access will gobble up a comma delimited file with its WizaRDS-
AT LEAST aCCESS97 WILL



Fri, 04 Feb 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Using a Data Control in VB5 accessing a user-level secure Access 97 DB

2. using ordinairy access to database without data control

3. Using Access 97 replication ID's with VB5 data control and other bound controls

4. Binding VB OLE Control to DB without using a data control

5. Importing data to access using Visual Basic

6. Importing data using Access 2000 and SQL 7

7. Using VB to Import Web Data in Access

8. Importing data from Excel to Access using VB???

9. Importing Data into Access using VB

10. Importing data from Excel to Access using VB???

11. Importing data into Access using VB?

12. Using the Microsoft Text Driver to import data into Access

 

 
Powered by phpBB® Forum Software