473,395 Members | 1,521 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

File selection problem

1
This script below is having problems with allow the selestion of *.mdb files off the network. Can anyone see the problem with the code?
[code]

Function ImportFile(strform As Form) As Boolean
Dim OpenFile As OPENFILENAME
Dim lReturn As Long
Dim sFilter As String
Dim ChosenFileName As String

ImportFile = True

OpenFile.lStructSize = Len(OpenFile)
OpenFile.hwndOwner = strform.Hwnd
sFilter = "Microsoft Access (*.mdb)" & Chr(0) & "*.mdb" & Chr(0) & _
"All Files (*.*)" & Chr(0) & "*.*" & Chr(0)
' "Text (*.TXT)" & Chr(0) & "*.TXT" & Chr(0) &
OpenFile.lpstrFilter = sFilter
OpenFile.nFilterIndex = 1
OpenFile.lpstrFile = String(257, 0)
OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1
OpenFile.lpstrFileTitle = OpenFile.lpstrFile
OpenFile.nMaxFileTitle = OpenFile.nMaxFile
OpenFile.lpstrInitialDir = "C:\"
OpenFile.lpstrTitle = "Select an Access Database"
OpenFile.flags = 0
lReturn = GetOpenFileName(OpenFile)
ChosenFileName = Left(OpenFile.lpstrFile, InStr(OpenFile.lpstrFile, ".") + 3)
If lReturn = 0 Then
MsgBox "A file was not selected!", vbInformation, "Select a File"
ImportFile = False
ElseIf LCase(Right(ChosenFileName, 4)) = ".mdb" Then
LinkTables (ChosenFileName)
Else
MsgBox "File must be an Access Database (*.mdb)!", vbOKOnly, "Error"
ImportFile = False
End If
End Function
Aug 29 '08 #1
2 1214
QVeen72
1,445 Expert 1GB
Hi,

Filter string should be given like this: (with a Single Pipe Character)

Expand|Select|Wrap|Line Numbers
  1. CommDlg.Filter = "Access Database (*.mdb)|*.mdb"
  2.  
REgards
Veena
Aug 30 '08 #2
Hello

Your problem is the sFilter line. Try this

Dim sFilter As String

sFilter = "Microsoft Access (*.mdb)|*.mdb"
sFilter += "|All Files (*.*)|*.*"

Me.OpenFileDialog1.Filter = sFilter
Me.OpenFileDialog1.ShowDialog()


To separate files type you need to use the pipe character. << | >>
Aug 31 '08 #3

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

Similar topics

1
by: John Pastrovick | last post by:
Is there a way to load an image locally (in the client) when a selection of a file is made using input type=file. The purpose is to allow selection of a file and put the image in the browser...
3
by: c j anderson, mcp | last post by:
I recently had a need to be able to highlight selected text in a web browser control (working code is posted below). Attempts to access the modified html source through the webbrowser or the...
5
by: CCLeasing | last post by:
Hello, I have searched google but can not find a straight forward answer to my problem. Hopefuly someone will be kind enough to offer their expertise. Please forgive if this seems a bit convoluted...
0
by: CCLeasing | last post by:
Hello, I have searched google but can not find a straight forward answer to my problem. Hopefuly someone will be kind enough to offer their expertise. Please forgive if this seems a bit convoluted...
2
by: ahynes | last post by:
HI folks, I'm a chem engineer with no VB programming knowledge (as you'll see from my question!) I want a script to open a .txt file, insert pre-defined text into the start and end of the...
2
by: ahynes | last post by:
HI folks, I need a script to open a .txt file, insert pre-defined text into the start and end of the file, then close teh saved file with a .nc extension. I'd like to have this so I can run it...
6
by: John | last post by:
Hi I am trying to save settings of controls on my form to a file so I can read them back later and recreate the controls on the form. I have figured out how to go through all controls and get...
2
by: clockworx05 | last post by:
:chomp: Hey guys i have an address book that needs to work. I have a header file, but my program says missing header file. here is my code for the program: #include <iostream> #include...
2
by: keclipse2525 | last post by:
I have been working on this for a little while now im using the library <fstream> and <iostream>. The object of my program is to read two separate files that contain different amounts of random...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.