Results 1 to 6 of 6
  1. #1
    ahmed.osama is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    3

    Copy Data

    hey guys,



    i'm new user for access 2010, what i need is to copy some data to a text file from a form?
    for example:
    i have a form have 3 fields, id, user & password;

    what i need is to generate a text file for the user field?

    any help please

  2. #2
    ahmed.osama is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    3
    any one can help please?

  3. #3
    GeekInOhio's Avatar
    GeekInOhio is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2012
    Posts
    25
    Here is a bit of code I use to create a list of all forms in my ADP and save them to a text file. It should give you a good starting point:

    Code:
        Dim obj As AccessObject
        Dim dbs As Object
        Dim myList As String
        Dim strdn As String
        
        Set dbs = Application.CurrentProject
        
        myList = Date & vbCr & vbLf
          
        For Each obj In dbs.AllForms
            strdn = obj.Name
            myList = myList & strdn & vbCr & vbLf
        Next obj
        
        'Write and save file
        Open "c:\Program Files\STEP\forms.txt" For Output As #2
        Print #2, myList
        Close #2
        
        'Open file to view
        ShellExecute 0, vbNullString, "c:\Program Files\STEP\forms.txt", vbNullString, vbNullString, vbNormalFocus

  4. #4
    ahmed.osama is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    3
    thanks,

    but where shall i put this code?

  5. #5
    GeekInOhio's Avatar
    GeekInOhio is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2012
    Posts
    25
    You'll need to adapt it, not copy and paste.

    You need to create a string that contains the values entered in your three text boxes, then save that string to the text file using what I've shown you above. As far as where to put it, I'd suggest adding a button to your form and putting it in the OnClick event of the button.

  6. #6
    GeekInOhio's Avatar
    GeekInOhio is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2012
    Posts
    25
    Here ya go, this has most everything you could ever want to know about using VBA to do file handling, including creating files, opening files and even appending to existing files: http://www.xtremevbtalk.com/showthread.php?t=123814

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Copy data from one form to another.
    By Gamberick in forum Forms
    Replies: 5
    Last Post: 01-18-2012, 02:26 AM
  2. copy data from one table to another
    By Sureshbabu in forum Access
    Replies: 1
    Last Post: 01-08-2012, 01:27 PM
  3. copy data error
    By markjkubicki in forum Programming
    Replies: 2
    Last Post: 12-28-2011, 10:01 AM
  4. COPY DATA and TRIM
    By Ed H in forum Access
    Replies: 1
    Last Post: 01-01-2009, 07:01 AM
  5. Replies: 0
    Last Post: 09-21-2008, 11:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums