By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,234 Members | 1,823 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,234 IT Pros & Developers. It's quick & easy.

Problem with Open Dialog Box

P: 4
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.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command4_Click()
  2. Dim strFilter As String
  3.    Dim strInputFileName As String
  4.     strFilter = ahtAddFilterItem(strFilter, "all Files (*.*)", "*.*")
  5.  
  6.     strInputFileName = ahtCommonFileOpenSave( _
  7.                             Filter:=strFilter, _
  8.                             OpenFile:=True, _
  9.                             DialogTitle:="Choose a file...", _
  10.                             Flags:=ahtOFN_HIDEREADONLY)
  11. End Sub
Appreciate your help
Thanks
Manoj Kumar
Feb 11 '09 #1
Share this Question
Share on Google+
4 Replies


NeoPa
Expert Mod 15k+
P: 31,419
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?
Feb 12 '09 #2

Expert 100+
P: 1,287
Take a look at DoCmd.TransferSpreadsheet Method.
Feb 12 '09 #3

P: 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
Feb 13 '09 #4

NeoPa
Expert Mod 15k+
P: 31,419
@manojspromantr
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.
Feb 13 '09 #5

Post your reply

Sign in to post your reply or Sign up for a free account.