dcsimg
Results 1 to 9 of 9

Thread: Pharsing of nos. of line into one populating as one recordset in Access thro VBA

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2018
    Posts
    3

    Pharsing of nos. of line into one populating as one recordset in Access thro VBA

    Dear All,

    I have a table with structure like this :

    f1, f2, f3, f4, f5 ,f6

    all is text type with 255 length

    I wanna populate some existed data into the fields form a text file, one structure of the text file like this.


    "text1", "text2", text3", "text4", text5", "text6"

    for the above, I can poupulate the data directly, expect below structure.


    "text1", "text2"
    "DITTO", "text3"
    "DITTO", "text4", text5"
    "DITTO", "text6"

    Dear All, I think I have to pharing the text before populate into the tabel but I have no ideas how to do this via Access VBA.

    Would anyone can advise me!

    Thank you so much.

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    23,729

    Re: Pharsing of nos. of line into one populating as one recordset in Access thro VBA

    is the text always in the same format?
    are there multiple records in the text file?
    is DITTO the actual text between fields?

    can you post a sample of an actual text file?
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    1,435

    Re: Pharsing of nos. of line into one populating as one recordset in Access thro VBA

    Pete,

    note the missing comma between "text2" and the first "DITTO" (linebreak!) (same for the following lines/DITTO's)
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    I say you're crazy not to!
    --------------------------------------------------------------------------------------------------
    For health reasons i try to avoid reading unformatted Code

  4. #4

    Thread Starter
    New Member
    Join Date
    Sep 2018
    Posts
    3

    Re: Pharsing of nos. of line into one populating as one recordset in Access thro VBA

    Quote Originally Posted by westconn1 View Post
    is the text always in the same format?
    are there multiple records in the text file?
    is DITTO the actual text between fields?

    can you post a sample of an actual text file?
    Actually, "Ditto" is a key words mean continuous to the upper line.

    The numbers of the occurrence of "Ditto" is various, sometimes less or sometime more .

    So I have to restructure from

    "text1", "text2"
    "DITTO", "text3"
    "DITTO", "text4", text5"
    "DITTO", "text6"

    To

    "text1", "text2","text3","text4", text5","text6"

    and populate to the table.

  5. #5
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    1,435

    Re: Pharsing of nos. of line into one populating as one recordset in Access thro VBA

    ?
    Why not just replace Linebreak and "DITTO" with empty string?
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    I say you're crazy not to!
    --------------------------------------------------------------------------------------------------
    For health reasons i try to avoid reading unformatted Code

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    23,729

    Re: Pharsing of nos. of line into one populating as one recordset in Access thro VBA

    note the missing comma between "text2" and the first "DITTO"
    Why not just replace Linebreak and "DITTO" with empty string?
    or replace with comma

    i note in all examples text5 has no leading quote, i presume that is just a typo?
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  7. #7

    Thread Starter
    New Member
    Join Date
    Sep 2018
    Posts
    3

    Re: Pharsing of nos. of line into one populating as one recordset in Access thro VBA

    Quote Originally Posted by westconn1 View Post
    or replace with comma

    i note in all examples text5 has no leading quote, i presume that is just a typo?
    Yes is a typo , it should be "text5"

  8. #8
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    1,435

    Re: Pharsing of nos. of line into one populating as one recordset in Access thro VBA

    Quote Originally Posted by westconn1 View Post
    or replace with comma
    Uh, Pete,

    in that case he would have 2 consecutive commas.
    There is already a comma after "DITTO"
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    I say you're crazy not to!
    --------------------------------------------------------------------------------------------------
    For health reasons i try to avoid reading unformatted Code

  9. #9
    PowerPoster
    Join Date
    Dec 2004
    Posts
    23,729

    Re: Pharsing of nos. of line into one populating as one recordset in Access thro VBA

    There is already a comma after "DITTO"
    oops
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width