Results 1 to 7 of 7

Thread: splitting a column in alphabetic folders?

Hybrid View

  1. #1
    Hyperactive Member nagasrikanth's Avatar
    Join Date
    Nov 2004
    Location
    India,Hyderabad.
    Posts
    420

    Re: splitting a column in alphabetic folders?

    im able to create upto directories...
    im not getting how to create files...
    can any body give me an example of creating files..
    The Difference between a Successful person and others is not a Lack of Knowledge,
    But rather a Lack of WILL

  2. #2
    Hyperactive Member nagasrikanth's Avatar
    Join Date
    Nov 2004
    Location
    India,Hyderabad.
    Posts
    420

    Re: splitting a column in alphabetic folders?

    well...goncha

    finally I got it..i dont know wether the process that im fallowing is right or not,
    but im acheving the target...
    chk the attachment once.
    Attached Files Attached Files
    The Difference between a Successful person and others is not a Lack of Knowledge,
    But rather a Lack of WILL

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2005
    Posts
    3

    Re: splitting a column in alphabetic folders?

    Hello!!

    Thank you for trying to help me, nagasrikanth!

    The file you attached contains only a database. Did you forget to add something?

    G.

  4. #4
    Hyperactive Member nagasrikanth's Avatar
    Join Date
    Nov 2004
    Location
    India,Hyderabad.
    Posts
    420

    Re: splitting a column in alphabetic folders?

    Nothing else is required...
    just chk out the database and in the forms open the form,and click the button...

    it will results u r folders and files in "C:\" Drive..
    The Difference between a Successful person and others is not a Lack of Knowledge,
    But rather a Lack of WILL

  5. #5

    Thread Starter
    New Member
    Join Date
    Nov 2005
    Posts
    3

    Re: splitting a column in alphabetic folders?

    I can not read the database direct from where i am.
    Could you please show me the code direct here in the forum instead, or send it to me as a message?

    Many thanks in advance for your time,
    G.

  6. #6
    Hyperactive Member nagasrikanth's Avatar
    Join Date
    Nov 2004
    Location
    India,Hyderabad.
    Posts
    420

    Re: splitting a column in alphabetic folders?

    okay...then...here is the code...
    first place u r data in a table named "table1" and then run this code by placing it in a form
    VB Code:
    1. Option Compare Database
    2. Option Explicit
    3. Private Declare Function CreateDirectory Lib "kernel32" Alias "CreateDirectoryA" (ByVal lpPathName As String, lpSecurityAttributes As SECURITY_ATTRIBUTES) As Long
    4. Private Type SECURITY_ATTRIBUTES
    5.     nLength As Long
    6.     lpSecurityDescriptor As Long
    7.     bInheritHandle As Long
    8. End Type
    9.  
    10.  
    11. Private Sub Command0_Click()
    12.     Dim Security As SECURITY_ATTRIBUTES
    13.     Dim prevletter
    14.     Dim fstletter
    15.     Dim lngHandle As Long
    16.     Dim rst As Recordset
    17.     Dim fs As New FileSystemObject
    18.     Dim flname
    19.     Dim fl
    20.     Set rst = CurrentDb.OpenRecordset("table1")
    21.     If Not rst.RecordCount = 0 Then
    22.         rst.MoveFirst
    23.         While Not rst.EOF
    24.         fstletter = Left(rst(0), 1)
    25.         If Not prevletter = fstletter Then
    26.             CreateDirectory "C:\" & fstletter, Security
    27.             prevletter = fstletter
    28.         End If
    29.         flname = fs.BuildPath("c:\" & fstletter, rst(0) & ".txt")
    30.         Set fl = fs.CreateTextFile(flname, True)
    31.         rst.MoveNext
    32.         Wend
    33.     End If
    34.  
    35.  
    36. End Sub
    The Difference between a Successful person and others is not a Lack of Knowledge,
    But rather a Lack of WILL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width