Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2012
    Posts
    54

    Unanswered: Conflictual Importations?

    Hi guys...
    I'm stucked on another bug issue(of course big for me!!!!) the problem is:
    For some reasons, I need to import in the same project three tables, one I'm been able to import thanks to your suggestion using a mix of vba and sql, the Second I've been able quite easily to import into access(it was an excell doc).
    the third one is getting me quit upset:
    I've transformed the file from excel to csv format since the excel importation seems to fail;
    I've just arranged to change the syntax of the first importing code to import the second file in my access table.
    But it seems to create conflict between the sub import 1 and the sub import 3... is it possible?????
    this is the syntax of the second importation:
    Code:
    sub p()
    Const G = "CREATE TABLE CPex (CD_MAD Text(40), SCHEMA Text(255));"
    CurrentDb.Execute G
    
    End Sub
    
    Sub Icsv()
    
        Dim LineData As String
        Dim inj As Integer
        inj = FreeFile
        Open "C:\Users\path..." For Input As #inj
        Do Until EOF(inj)
            Line Input #inj, LineData
            InsertRow "CPex", LineData
        Loop
        Close #inj
        
    End Sub
        Sub InsertRow2(ByVal LineData As String)
          
    
        Const c_SQL As String = "INSERT INTO CPex (CD_MAD, SCHEMA) VALUES ('AA1', '2') ;"
        Dim strQ As String
        
        strQ = Replace(c_SQL, "AA1", Mid(LineData, 1, 3))
        strQ = Replace(c_SQL, "2", Mid(LineData, 5, 120))
        
       Debug.Print strQ: Stop
            
        CurrentDb.Execute strQ
        
            
        End Sub
    the source file is like this:
    AA1; C099923 D0326840
    why it does't work??????

  2. #2
    Join Date
    May 2004
    Location
    New York State
    Posts
    1,178
    Code:
        Dim strQ As String
        
        strQ = Replace(c_SQL, "AA1", Mid(LineData, 1, 3))
        strQ = Replace(c_SQL, "2", Mid(LineData, 5, 120))
    strQ is dimmed as a string, but there are no quotes. Could that be the problem?

    Sam

  3. #3
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    1. In the code you posted, the procedure Icsv calls the procedure "InsertRow":
    Code:
    InsertRow "CPex", LineData
    While you posted the code for a procedure named "InsertRow2"
    Code:
    Sub InsertRow2(ByVal LineData As String)
    2. You wrote that:
    But it seems to create conflict between the sub import 1 and the sub import 3... is it possible?????
    this is the syntax of the second importation:
    - What are "sub import 1" and "sub import 3"?
    - What precisely do you mean with "create conflict" (error code, unexpected results, ...)?
    - Why did you post the code for the second importation if you have troubles with the first and the third?

    @Sam: "c_SQL" is declared as a string constant, so I don't think that could be the problem:
    Code:
    Const c_SQL As String = "INSERT INTO CPex (CD_MAD, SCHEMA) VALUES ('AA1', '2') ;"
    Have a nice day!

  4. #4
    Join Date
    Jan 2012
    Posts
    54
    I've imported it from excel, still I'don't know where is the problem in this code since I've implemented all your suggestions, I'll promise to review this procedure in order to came to a solution!!
    Thank you all, as usual!!!!!

Posting Permissions

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