Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA 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 September 13th, 2005, 01:43 PM
Registered User
 
Join Date: Sep 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default VBA access List data to text file

hello ..

I like to make a module that will write simple data from a table to text file.

I made some resarch and I got everything OK .. just how do I read data from a table in VBA (inside access) how to connect to the table ?

thank you

HI :-)
 
Old September 13th, 2005, 01:47 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Are you using ADO or DAO (for the connection to the local table)?



mmcdonal
 
Old September 14th, 2005, 12:30 AM
Registered User
 
Join Date: Sep 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I don't use any thing right now!

what is the easiest one (I'm mostly a Linux guy so it's quite new to me .. but I'm learning fast).

I would like to know your suggestions

I already made the code that write the data to a file and save it in the right place.

but it's just how to connect to a table (I know SQL very well) just the MS stuff is all new to me ;)

thank you for your replay

HI :-)
 
Old September 14th, 2005, 02:56 AM
Registered User
 
Join Date: Sep 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ok when I try to use "Dim db As Database" it shows me error message!

HI :-)
 
Old September 14th, 2005, 03:39 AM
Registered User
 
Join Date: Sep 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

here is my code that I wrote to creat a mailing list !

I know there is something wrong !!! but I can not find where

Sub list()
    Dim dteDOB As String
    dteDOB = InputBox("Please enter your list date as 99 or 02", "Create List")
    txtDOB = dteDOB

    Dim fs, a
    Dim dbcurr As DAO.Database
    Set dbcurr = CurrentDb()
    Dim rsSubjects As DAO.Recordset
    Set rsSubjects = dbcurr.OpenRecordset("SELECT users.email FROM users WHERE year = '" & txtDOB & "';")

    Set fs = CreateObject("Scripting.FileSystemObject")
    Set a = fs.CreateTextFile("c:\" & "grads" & txtDOB & "@domain.com.txt", True)

    a.WriteLine "# Mailing List file"
    a.WriteLine "#"

    Do Until rsSubjects.EOF
        a.WriteLine rsSubjects! [email]
        rsSubjects.MoveNext
    Loop

    a.Close

End Sub

do I have to make some special settings in Access so it will work?

is it big deal to use DAO.Database & ADO.Database

what is the diffrence !

I use Access 2003


Thank you again for your time

HI :-)
 
Old September 14th, 2005, 07:00 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

You are getting the error message because you are using DAO instead of ADO, and you have not selected DAO as a reference. You also will need to move DAO up in the list above ADO so that Access checks DAO first, otherwise ADO might still return an error.


mmcdonal
 
Old September 15th, 2005, 04:04 PM
Registered User
 
Join Date: Sep 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks allot ... it's worke now :-)

HI :-)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Link a text file to Access using VBA wscheiman Access VBA 1 June 30th, 2013 07:02 PM
List Available Fonts in Access VBA Nadine Access VBA 0 March 19th, 2008 12:24 PM
Text File-Newbie VBA Access mbeirn Access VBA 1 October 6th, 2005 07:18 AM
import data from text file to excel(VBA) topr Excel VBA 2 August 26th, 2004 11:36 PM
VBA Access Automatic List Problem Thaleiadan Access VBA 1 March 10th, 2004 09:18 AM





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