Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2005
    Posts
    29

    Unanswered: hi all need some help or import cmd

    Hi i'm quite new to access and was figuring out how to program using the DoCmd.TransferSpreadsheet.

    I have a code attached to a a button like below

    DoCmd.TransferSpreadsheet acImport, 8, "Bony2", "C:\Documents and Settings\XXXX\Desktop\3.xls", True, "A1:K80"

    the probelm is i want the user to specified the cell range to import. Maybe i can give a text box for user to enter that value but how to transfer that value back to the above code.

    If i don't want the user to specify the range and leave it blank in the above code....access always prompt me that a field doesn't exist in my access database. However i had everything in tact and the required field and property done up. If i specified the range then everything is ok. So anybody can advice?

    Thanks in a dvance for any help i could get.

  2. #2
    Join Date
    Feb 2005
    Location
    England.
    Posts
    232
    I'd suggest your best bet would be to put a text box onto a form where the button resides. Then I'd suggest your code to be ...

    Private Sub cmdTranser_Click()

    Dim strRange as string

    txtRange.SetFocus

    strRange = txtRange.text

    DoCmd.TransferSpreadsheet acImport, 8, "Bony2", "C:\Documents and Settings\XXXX\Desktop\3.xls", True, strRange

    End Sub

    Something like this should work, although the range the user specifies would have to have the ':' in there too.

    Hope this works and hope it help.

    DaveO.

  3. #3
    Join Date
    Feb 2005
    Posts
    29
    Hi daveo61 thank for your help. Haven't try yet but i think it will work...thanks alot

Posting Permissions

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