Results 1 to 8 of 8
  1. #1
    mike02 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2012
    Posts
    245

    clarification with transfer commands

    hey,
    following a guide to writing these commands online however i keep getting compile errors and i cant get it to figure out for some reason.


    Code:
    Docmd.TransferSpreadsheet(acImport,a cSpreadsheet, me.cboTablesList, me.txtgetfile, True-1, ,)
    Code:
    Docmd.TransferText (acImportDelim, , me.cboTablesList, me.txtgetfile, true (-1), ,)
    I select the table name from a combo box on my form and i select the file location from a txtbox which takes the file command from a promt menu when i select the file. the first field is the field headding names. one runs when txt file is selected and the other runs when excel is selected. (Two check boxes on my form)

  2. #2
    help_me_with_access is offline help_me_with_excel
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    262
    docmd.transferspreadsheet is *not* supposed to be followed by () marks to enclose the arguments in. take them out. also, doesn't look like you're seperating your arguments appropriately anyway. what is "True-1". that obviously won't work.

    if that was intentional, syntax like that is not even standard in any modern language. booleans in visual basic take on 2 forms:

    0/-1

    True/False

  3. #3
    mike02 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2012
    Posts
    245
    the site said you put True(-1) to indicate that the 1st Row is your field names ? how do you indicate that?
    thanks!

  4. #4
    mike02 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2012
    Posts
    245
    also, If im running if to pick which command i want ran, then would i go

    If Me.checkexcel =1 Then

    docmd...

    Else

    If Me.txtfile =1 Then

    docmd.......

    End If
    End If

    or how would i say to select the box that is checked.

    my check box names are, checkexcel and txtfile

  5. #5
    help_me_with_access is offline help_me_with_excel
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    262
    let us go with 1 question at a time here Mike. So here is your first one...

    Quote Originally Posted by mike02 View Post
    the site said you put True(-1) to indicate that the 1st Row is your field names ? how do you indicate that?
    thanks!
    WHAT site are you talking about? Whatever it was, they were using redundancies to get the point across, probably because redundancies (banging the head against the wall many times over and over and over) seems to be the only way out professionals have anymore in order to get a point across to lesser-experienced developers. or even users that think they know something about development.

    so in other words, if your article said "True(-1)", what it is saying is: "True, in other words use -1 because that is the same thing as typing the word TRUE into the development environment". That is classic for XML-based office help articles (I think). and then too, it should be classic for MS'S MSDN site, which is copied verbatim from office help files if you're dealing with any office program.

    now on to your next question, what was that again? I'm not quite following...

  6. #6
    mike02 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2012
    Posts
    245
    thanks, i believe i interpreted the site wrong meaning, they aid true(-1) saying that -1 is true? i dont kow, but thanks for clearing that up. my second question is i have to check boxes on my form. on is named excel, and the other txtfile. now i want to call the cmd codes based on what is check. meaning if excel is checked then to run transfer spread sheet, and if txtfile is checked then to run transfertext. I tried using if statements as above. however the value isnt 1. And it is not rnning the code properly. how would you run each command based on the check box selected?
    Here is my complete form code:
    Code:
    Private Sub btnrunoutput_Click()
    'check for empty comboboxes
    If IsNull(Me.cboTablesList) Then
        MsgBox "Please select a table"
        Exit Sub
    Else
    If IsNull(Me.excel) Or IsNull(Me.txtfile) Then
        MsgBox "Please select file type"
        Exit Sub
    Else
    If IsNull(Me.txtgetfile) Then
        MsgBox "Please select a file"
        Exit Sub
    End If
    End If
    End If
     'Import the data
     'Case 1 excel file
    If Me.excel = 1 Then
    DoCmd.TransferSpreadsheet acImport, acspreadsheet12XML, "me.cboTablesList", "me.txtgetfile", True
    Else
     'Case 2 text file
    If Me.txtfile = 1 Then
    DoCmd.TransferText acImportDelim, , "me.cboTablesList", "me.txtgetfile", True
    End If
    End If
    End Sub

  7. #7
    mike02 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2012
    Posts
    245
    i am getting error 3011,meaning it doesnt find the object in the file path. this is because it is not recognicing the value of me path to the textboc but instead the the code to tell it to recognize it to the value:

    ie.

    me.txtgetfile is what it is looking for but it should be using the value whats inside that text box? any ideas?

  8. #8
    mike02 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2012
    Posts
    245
    i changed up the code abit to correct that.

    Code:
    Private Sub btnrunoutput_Click()
    'check for empty comboboxes
    If IsNull(Me.cboTablesList) Then
        MsgBox "Please select a table"
        Exit Sub
    Else
    If IsNull(Me.txtgetfile) Then
        MsgBox "Please select a file"
        Exit Sub
    End If
    End If
    Dim strPath As String
        Dim strSpec As String
        Dim strTbl As String
        
        strTbl = Me.cboTablesList
        trPath = Me.txtgetfile
        
    DoCmd.TransferText acImportFixed, , strTbl, strPath, True
        
        ' A message box indicating the process has completed.
        'MsgBox ("The file has completed its transfer")
    End Sub
    It says i need a specification. what would i put for that, this part confuses me. I want to add this in

    Code:
    Private Sub btnrunoutput_Click()
    'check for empty comboboxes
    If IsNull(Me.cboTablesList) Then
    MsgBox "Please select a table"
    Exit Sub
    Else
    If IsNull(Me.txtgetfile) Then
    MsgBox "Please select a file"
    Exit Sub
    End If
    End If
    Dim strPath As String
    Dim strSpec As String
    Dim strTbl As String
    
    strTbl = Me.cboTablesList
    trPath = Me.txtgetfile
    strSpec = "what do i put here?"
    
    DoCmd.TransferText acImportFixed, strSpec, strTbl, strPath, True
    
    ' A message box indicating the process has completed.
    'MsgBox ("The file has completed its transfer")
    End Sub
    What would i set the string equal too? can some one explain this to me the idea of specifications etc? the offic site doesnt clarify it well for me, thanks in advance

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Button Commands
    By JayX in forum Access
    Replies: 13
    Last Post: 12-09-2011, 05:37 PM
  2. If __ Then __ type commands in queries?
    By TUPJK in forum Access
    Replies: 7
    Last Post: 06-20-2011, 01:28 PM
  3. missing commands and options dialog box
    By marlowj30 in forum Access
    Replies: 1
    Last Post: 06-15-2011, 01:38 PM
  4. Basic commands in Access 2007
    By johnkl49 in forum Access
    Replies: 2
    Last Post: 09-23-2010, 04:07 PM
  5. Replies: 0
    Last Post: 09-08-2009, 11:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums