Consulting

Page 5 of 9 FirstFirst ... 3 4 5 6 7 ... LastLast
Results 81 to 100 of 162

Thread: File Dialog-Browse/Save/Append

  1. #81
    VBAX Regular
    Joined
    May 2017
    Posts
    98
    Location
    The commas will align the data in the approprioate fields for the import.

  2. #82
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    Andy, how about
    datastring = ",,,,,Data added " * Date()
    that will tell anyone looking at the data when each append was made.

  3. #83
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    I am not sure what this means
    "The commas will align the data in the approprioate fields for the import."



    Do you mean importing in to Access or Excel?

  4. #84
    VBAX Regular
    Joined
    May 2017
    Posts
    98
    Location
    Sorry for the confusion. Yeah after all the moving and copying files, it's time to import the master file to Access. This is where we both were saying Access should have been used to let Access handle the importing/appending for each file type.

    By addidng the 3 commas, it separated the first field of the appended data to the correct field of the table and set all subsequent fields correctly.

  5. #85
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    So, can you explain the sequence of events?
    Copy file or append to Master
    Import master to Access
    Copy fille or append to Master
    Import master to Access again?

  6. #86
    VBAX Regular
    Joined
    May 2017
    Posts
    98
    Location
    Evidently all of the copy file and append file will have to happen prior to importing to Access. After the master is imported to Access, no more appending will occur. So I guess if something is missed to bad so sad. You'll have to start another DB for any other data. Not my show.

    So the header rows of the files are used as field names for the table when they are imported to access. When you append a file, it appends everything obviously including the header rows. Creating a file that header row of the intial master file a. The file is structured as header rows, all the data, then after an append, header rows, and all the data. When I import the appended master file, Access will import to the last data set before the header rows are repeated. I've got to omit the header rows when appending to the master file. Didn't think that would happen because when I was importing a file at a time that did not occur.

  7. #87
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    You could allow the Header rows to be inported and then use a Delete query to remove them.
    I think you can specify whether or not a file has header rows or not.
    But I also have a VBA import routine that could probably be modified to ignore them during import.
    Are you using VBA, docmdimport or a Data Import to bring in the data to Access?

  8. #88
    VBAX Regular
    Joined
    May 2017
    Posts
    98
    Location
    If that was confusing, i'm trying to say omit the header rows of an append file to the master. The master already has the header rows.

  9. #89
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    OK, of course that is possible, the code that I provided on your previous post skips the first line of code to avoid the headings.
    Have you forgotten it already?

    ps going out for a while so won't be able to answer until I get back.

  10. #90
    VBAX Regular
    Joined
    May 2017
    Posts
    98
    Location
    We've had a few post going back and forth so cut me some slack. jk
    I'll go back and look. Is it just to remove the first line? Because they are all different. Some 2 lines, some 3, and some not the complete line and the data set begins.

  11. #91
    VBAX Regular
    Joined
    May 2017
    Posts
    98
    Location
    You're referring to the import and not omitting for an append, correct?

  12. #92
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    It was the more than 265 fields question, that was you wasn't it?
    It was this line of code
    If reccount > 1 Then ' process if not heading record
    where we were using reccount, in this one we aren't currently using a counter be we could.
    Or as I said you can do it in the import routine or even after the data has been imported by deleting any offending records.

  13. #93
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    Hey what do mean cut you some slack, I am the one who is 70 with fading brain cells.

  14. #94
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location

    My brain hurts
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  15. #95
    VBAX Regular
    Joined
    May 2017
    Posts
    98
    Location
    I was joking around anyways. 70, I would have never know.

    Just so I'm putting the problem statement out there. Master file is in the directory and it has it's header rows for the file. A second file is appended to master file and it also brings the header rows with it. When trying to import using the routine you are referring to, it imports and stops where the appended file header row begins. So the newly appended
    master file looks like this: Header rows - initial master file data - Header rows (from appending file) - data (from appending file).

    I can see how using what was earlier used to overlook the headers but not sure how to go about overlooking both sets of headers rows as they will be downstream in the file and not the first rows of the file. And the second set of headers will be located differently for each of the five file types. Thats why I was hoping to omit the header rows from the append file in during that routine.

    I know this is all crazy.

  16. #96
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    Sam, I am currently working on three separate databases, it keeps the old brain cells ticking over, I also post on Tech Guys,where the other 2 are, which used to be a sister forum to VBAX, I have 19000 posts over there.

  17. #97
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    The routine that I wrote for your previous post ommits the header rows during import and the same method can easily be used to ommit the header during the Append operation.
    The only problem is if it is over more than one input "line", unless you know it in advance if it then you can ommit as many rows as necessary.

  18. #98
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    Andy, this should do it
    Dim sDest As String, firstfile As String, filecopied As Integer, reccount As Integer
    and
    Appendsub:
    MsgBox "current file appending to - " & FileFound & " from - " & FileName
    reccount = 0
    Open firstfile For Input As #1
    Open sDest & FileFound For Append As #2
    Do Until EOF(1)
        Line Input #1, datastring
        If reccount > 1 Then
            Print #2, datastring
        End If
    reccount = reccount + 1
    Loop
    Close #1
    Close #2
    MsgBox "data transferred to " & FileFound
    Return
    This line could be
    If reccount > 1 Then
    If reccount >2 Then
    or
    If reccount > 3 Then

  19. #99
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    This is an interesting, if easy, problem and I would like to work on it, but I am not going to read the previous 97 posts to figure out the data structure of Andy's situation.

    I don't even know if my speculation in that regard, in post #60, was accurate.

    Don't let your chest swell too much, I am 67 and this is my hobby too, also to keep my b.b.b.brain active when it is too hot outside to build stuff. If you go back far enough, you can find my name on a few other forums, even had my own, but it was getting too much like work, so I killed mine and dropped out of the rest and only work on the extremely easy and the most interesting projects here.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  20. #100
    VBAX Regular
    Joined
    May 2017
    Posts
    98
    Location
    So do the other lines need to be added? I added what OBP posted and the data append actually stopped working. It ran the procedure but didn't append any data.

    SamT your insight and comments are appreciated as well.

Posting Permissions

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