Results 1 to 5 of 5
  1. #1
    akinamon is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2014
    Posts
    7

    bound a text box name to the excel`name importation

    hey guys,



    i need your help

    i am importing an excel file

    for example, the file named ("Assets"), but every time i import a different file.

    my question is, how do i bound the excel's file name to an unbound text box name (shown in a form.)?

    thanks

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    You need to select the file to put in the box.
    On button click:
    usage:
    txtBox = UserPick1File("c:\folder\")

    Code:
    Public Function UserPick1File(ByVal pvFilter, Optional pvPath)
    Dim strTable As String
    Dim strFilePath As String
    Dim sDialog As String, sDecr  As String, sExt As String
    
    '===================
    'YOU MUST ADD REFERENCE : Microsoft Office 11.0 Object Library, in vbe menu, TOOLS, REFERENCES
    '===================
    With Application.FileDialog(msoFileDialogFilePicker)   
        .AllowMultiSelect = False
        .Title = "Locate a file to Import"
        .ButtonName = "Import"
        .Filters.Clear
        .Filters.Add "Excel Files", "*.xls;*.xlsx"
        .Filters.Add "All Files", "*.*"
        .InitialFileName = "c:\"
        .InitialView = msoFileDialogViewList    'msoFileDialogViewThumbnail
        
            If .Show = 0 Then
               'There is a problem
               Exit Function
            End If
        
        'Save the first file selected
        UserPick1File = Trim(.SelectedItems(1))
    End With
    End Function

  3. #3
    akinamon is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2014
    Posts
    7
    thanks, i will try it.

    now, how do i bound another text box to specific field name from the table i have just import the data from excel
    for example, i want to bound the textbox' name to the field "street name" (column 1 in the table)

  4. #4
    akinamon is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2014
    Posts
    7
    hey there,
    how do i connect this function to "Private Sub NavigationButton9_Click()"?

  5. #5
    akinamon is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2014
    Posts
    7
    Quote Originally Posted by ranman256 View Post
    You need to select the file to put in the box.
    On button click:
    usage:
    txtBox = UserPick1File("c:\folder\")

    Code:
    Public Function UserPick1File(ByVal pvFilter, Optional pvPath)
    Dim strTable As String
    Dim strFilePath As String
    Dim sDialog As String, sDecr  As String, sExt As String
    
    '===================
    'YOU MUST ADD REFERENCE : Microsoft Office 11.0 Object Library, in vbe menu, TOOLS, REFERENCES
    '===================
    With Application.FileDialog(msoFileDialogFilePicker)   
        .AllowMultiSelect = False
        .Title = "Locate a file to Import"
        .ButtonName = "Import"
        .Filters.Clear
        .Filters.Add "Excel Files", "*.xls;*.xlsx"
        .Filters.Add "All Files", "*.*"
        .InitialFileName = "c:\"
        .InitialView = msoFileDialogViewList    'msoFileDialogViewThumbnail
        
            If .Show = 0 Then
               'There is a problem
               Exit Function
            End If
        
        'Save the first file selected
        UserPick1File = Trim(.SelectedItems(1))
    End With
    End Function
    hey ranman,

    where do i add the command: "DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, "TblAtarim_from_Mahog", StrFileName, True?" in your function so the the import will Succeed?

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

Similar Threads

  1. Replies: 6
    Last Post: 01-30-2014, 05:57 PM
  2. Replies: 2
    Last Post: 06-11-2012, 09:37 AM
  3. Text box bound to combo box
    By Tari in forum Forms
    Replies: 4
    Last Post: 01-11-2012, 02:19 PM
  4. How to bound a text box
    By bundy75 in forum Forms
    Replies: 10
    Last Post: 07-30-2010, 02:50 PM
  5. I can't enter text in a bound text box
    By Jerry8989 in forum Forms
    Replies: 3
    Last Post: 10-05-2009, 11:52 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