[AccessD] TransferText Failling

Henry Simpson hsimpson88 at hotmail.com
Tue Mar 11 13:49:00 CST 2003


DAO is assumed with CurrentDb:  copy the little sub below and watch it choke 
on the CurrentDb loop.  The reason is, CurrentDb is a function that returns 
an implicit object variable pointing at a database object.  It is not an 
object variable in and of itself.  It returns a new pointer each time it is 
called so the For Each loop can never work as this loop requires a 
persistent object.  No problem for the db object variable.

Sub DBvsCurDB()
Dim db As Database
Dim tdf As TableDef

Set db = CurrentDb
For Each tdf In db.TableDefs
    MsgBox tdf.Name
Next
For Each tdf In CurrentDb
    MsgBox tdf.Name
Next
End Sub

Hen





>From: Drew Wutka <DWUTKA at marlow.com>
>Reply-To: accessd at databaseadvisors.com
>To: "'accessd at databaseadvisors.com'" <accessd at databaseadvisors.com>
>Subject: RE: [AccessD] TransferText Failling
>Date: Tue, 11 Mar 2003 13:00:20 -0600
>
>I believe there actually is.  From what I remember, there was some issue
>with using CurrentDB, that it could fail for some reason with certain
>circumstances, but for the life of me, I don't remember what they were.
>
>I personally have never had a problem with using CurrentDB, in fact, I had
>the opposite, I had a switchboard (on a db I didn't make), where MS's code
>set db=currentDB, and it was failing.  Replacing the variable object with
>just plain CurrentDB solved the problem.
>
>Odd, eh?
>
>Drew
>
>-----Original Message-----
>From: Rocky Smolin - Beach Access Software [mailto:bchacc at san.rr.com]
>Sent: Tuesday, March 11, 2003 12:23 AM
>To: accessd at databaseadvisors.com
>Subject: Re: [AccessD] TransferText Failling
>
>
>Drew:
>
>Is there any advantage to using CurrentDB. vs set db=CurrentDB and using db
>as the object?
>
>Rocky
>
>----- Original Message -----
>From: "Drew Wutka" <DWUTKA at marlow.com>
>To: <accessd at databaseadvisors.com>
>Sent: Monday, March 10, 2003 2:52 PM
>Subject: RE: [AccessD] TransferText Failling
>
>
> > Here's my code....just writing it in the email..it's really simple to 
>do.
> >
> > Function DumpRecordset(strSQL as String,strFileName as String)
> > Dim f As Long
> > Dim rs As recordset
> > Dim strData as String
> > dim i As Long
> > set rs=CurrentDB.OpenRecordset(strSQL) 'this is for Access 97 and DAO
> > if rs.eof=False then rs.movefirst
> > f=FreeFile
> > If Dir(strFileName)<>"" Then Kill strFileName
> > Open strFileName for binary access read as f
> > Do Until rs.eof=True
> > strData=""
> > for i=0 to rs.Field.Count-1
> > strData=strData & rs.Field(i).Value & ","
> > Next i
> > strData=Left(strData,len(strData)-1) & vbcrlf
> > Put f,,strData
> > rs.movenext
> > loop
> > rs.close
> > Close f
> > End Function
> >
> > All in all, pretty simple code.  (You can change the "," to whatever
> > delimiter you want.
> >
> > Drew
> >
> > -----Original Message-----
> > From: Hale, Jim [mailto:jim.hale at fleetpride.com]
> > Sent: Monday, March 10, 2003 4:13 PM
> > To: 'accessd at databaseadvisors.com'
> > Subject: RE: [AccessD] TransferText Failling
> >
> >
> > Seth,
> > I happened to be writing a little routine to dump plan data to a text 
>file
> > so the mention of your code was very timely. Thanks! several comments: 
>If
> > the file doesn't exist the killfile line gives an error. I added a
>filexists
> > test. Second
> > "Open strOutfile For Binary As intFileDesc" doesn't seem to work with 
>the
> > Print statement. I changed binary to Append and the code works.
> >
> > I need my amount field in the text file formatted as "-####.##"
>but -2000.00
> > is printed as -2000; 2000.20 is printed as 2000.2, etc. How can this be
> > correctly formatted in the print statement?
> > Regards,
> > Jim Hale
> >
> > -----Original Message-----
> > From: Seth Galitzer [mailto:sgsax at ksu.edu]
> > Sent: Monday, March 10, 2003 1:32 PM
> > To: accessd
> > Subject: Re: [AccessD] TransferText Failling
> >
> >
> > Rocky,
> >
> > Dump TransferText like a bad prom date and use file I/O manually to
> > generate your text file.  You have much more control of the output and I
> > have NEVER had it fail on me.  I've got sample code on my website.  Look
> > under Downloads for "File I/O in VB".  There should be enough there to
> > get you started.  I'd be happy to answer any questions if you have any.
> >
> > Seth
> >
> > On Mon, 2003-03-10 at 12:07, Rocky Smolin - Beach Access Software wrote:
> > > Dear List
> > >
> > > I'm trying to use the TransferText method of exporting a table to a
>comma
> > delimited file.  I get "Error 3027: Cannot Update.  Database or object 
>is
> > read-only" when issuing:
> > >
> > > DoCmd.TransferText acExportDelim, , "tblAddRooms", varFileName
> > >
> > > where varFileName contains a valid path and file name.  Has anyone 
>seen
> > this before? I have but can't remember why or what the fix was.
> > >
> > > MTIA,
> > >
> > > Rocky Smolin
> > > Beach Access Software
> > >
> > >
> > --
> > Seth Galitzer sgsax at ksu.edu
> > Computing Specialist http://puma.agron.ksu.edu/~sgsax
> > Dept. of Plant Pathology
> > Kansas State University
> >
> > _______________________________________________
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > http://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> > _______________________________________________
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > http://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> > _______________________________________________
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > http://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
>
>
>_______________________________________________
>AccessD mailing list
>AccessD at databaseadvisors.com
>http://databaseadvisors.com/mailman/listinfo/accessd
>Website: http://www.databaseadvisors.com
>_______________________________________________
>AccessD mailing list
>AccessD at databaseadvisors.com
>http://databaseadvisors.com/mailman/listinfo/accessd
>Website: http://www.databaseadvisors.com


_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online  
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963




More information about the AccessD mailing list