Click to See Complete Forum and Search --> : Microsoft Access 97 Problem


mardukk
March 21st, 2001, 05:06 PM
Hey All.. I got this little mission if you choose to help that would be great..

Heres what it is:
-----------------
I have 1 table (In Microsoft Access 97) that has a lot of information in it that I need to export to a text file (I know i can use transfertextmethod and Textstream methods). But, here is the catch.. Since it is going to be imported to an application that can import from text files I need to make sure that the code 1) Kills the Text File That already exists.. 2) Looks into the table (tblRep) and finds the last entry that was exported to the textfile 3) Then exports only the items that come after the last time (so what the user add's after they hit the button) ..

It can not append to the old text file that is create from the time before when the button is pressed.. so each time the button is pressed a new text file needs to be created with only the new information
---------------------
If someone could give a code example on how to do this it would be great..

Thanks

Iouri
March 21st, 2001, 08:15 PM
1.Open recordset with new records only (which you want to write to the text file). Here you will apply some criteria or use SQL which will select these records.
for example

sSQL = "select * from YourTable where TimeField > " & LastTransferringTime

where LastTransferringTime is the time when you did the last upload to the text file. You can add the field which will hold LastTransferTime info

2.Create an ini file where you will keep the name of the last created file #

3.read an ini file number and add 1 to it

4.
dim iFile as integer

iFile -> take from ini file and add 1
Do while not rs.eof
Open "c:\temp\" & iFile & ".txt" For Output As #1 'to write to
Print #1, rs!YourField
Loop
Close #1

The new file will be created.


Iouri Boutchkine
iouri@hotsheet.com