Problem with Open Dialog Box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • manojspromantr
    New Member
    • Feb 2009
    • 4

    #1

    Problem with Open Dialog Box

    Hi Friends

    I am trying to design a form where i need to browse a excel file using a open dialog box & append the same in a Table at the database.Any how i have taken care that the Table fields are in same order as the Excel file does.

    Please have a look at the below codes which i used to open a "Open Dialog Box" which is working fine.

    Now i want that when ever i select the File & click open the data in the file should get updated to the existing table deleting the existing data.

    Can any one help me out in this regard.
    Code:
    Private Sub Command4_Click()
    Dim strFilter As String
       Dim strInputFileName As String
        strFilter = ahtAddFilterItem(strFilter, "all Files (*.*)", "*.*")
    
        strInputFileName = ahtCommonFileOpenSave( _
                                Filter:=strFilter, _
                                OpenFile:=True, _
                                DialogTitle:="Choose a file...", _
                                Flags:=ahtOFN_HIDEREADONLY)
    End Sub
    Appreciate your help
    Thanks
    Manoj Kumar
    Last edited by NeoPa; Feb 12 '09, 02:13 PM. Reason: Please use the [CODE] tags provided
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32669

    #2
    Hi,

    I moved your question to the correct forum and edited the title for the typo.

    What is not clear from the question is which application the code is running in. Access or Excel?

    Comment

    • ChipR
      Recognized Expert Top Contributor
      • Jul 2008
      • 1289

      #3
      Take a look at DoCmd.TransferS preadsheet Method.

      Comment

      • manojspromantr
        New Member
        • Feb 2009
        • 4

        #4
        Thanks for your reply.

        This works if i specify the file name. Is there a way to import any excel file with any name.

        Now i need to give a specific file name. What if i change the file name & fiels are same as per the Table. do i need to go each & every time & change the file name in the codes.


        Thanks
        Manoj Kumar

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32669

          #5
          Originally posted by manojspromantr
          Now i need to give a specific file name. What if i change the file name & fiels are same as per the Table. do i need to go each & every time & change the file name in the codes.
          No. The filename can be provided to the procedure either as a string literal or as a variable.

          Post in you currently working (and compiled) code, and we can look at explaining in context.

          Comment

          Working...