If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > Conflictual Importations?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-31-12, 10:25
jsirico jsirico is offline
Registered User
 
Join Date: Jan 2012
Posts: 54
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??????
Reply With Quote
  #2 (permalink)  
Old 01-31-12, 13:08
Sam Landy Sam Landy is offline
Registered User
 
Join Date: May 2004
Location: New York State
Posts: 931
Quote:
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
Reply With Quote
  #3 (permalink)  
Old 01-31-12, 13:43
Sinndho Sinndho is offline
Registered User
 
Join Date: Mar 2009
Posts: 3,446
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:
Quote:
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!
Reply With Quote
  #4 (permalink)  
Old 02-01-12, 04:11
jsirico jsirico is offline
Registered User
 
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!!!!!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On