OpenDialogBox in Access

  • Thread starter Thread starter leojordao
  • Start date Start date
L

leojordao

Dear Friends,

I need make a import txt file for a table in access with a
speciphicaton, but i cant to use the command transfer text, why this
final user have find the txt file.

How can I implement this code?

Operating System: Win 2000

Thank's for attention!
 
Hi Leojordao,

If I understand your question correctly, you cannot hard-code the name of the text file
because your user needs to have the ability to select the file to import. Is this
correct? If so, send me a private e-mail with a valid e-mail address and I will send you
back a sample database. It uses a common dialog, implemented using an API call, to allow
one to select a file. It also allows you to either link or import the table.

Tom

AOS168 at comcast dot net

_______________________________________


Dear Friends,

I need make a import txt file for a table in access with a
speciphicaton, but i cant to use the command transfer text, why this
final user have find the txt file.

How can I implement this code?

Operating System: Win 2000

Thank's for attention!
 
Ok Tom, you unnderstand my problem.

I´m testing now the Douglas solution, but i´m working with access 200
and this solution is to access 97.

Please, can you will send me a sample database?

Thank´s for your help.

(e-mail address removed)

Leonardo Jordã
 
Hello Leonardo,

I just sent you my sample database. It is an Access 2000 database. You mentioned that
you need to have something that will work in Access 97. Currently, the VBA code in this
database is using a function (CurrentProject.path) which was introduced with Access 2000.
I'll have to see if there is a simple way to rework it for Access 97. It shouldn't be too
hard. I'm a little busy for the next couple of days, but I will look into sending you an
Access 97 version that works.

Tom
________________________________________


Ok Tom, you unnderstand my problem.

I´m testing now the Douglas solution, but i´m working with access 2000
and this solution is to access 97.

Please, can you will send me a sample database?

Thank´s for your help.

leojordao AT hotmail DOT com

Leonardo Jordão
 
The API solution I pointed to isn't specific to any version of Access: it
will work in Access 2000.
 
Doug,

My sample works fine in Access 2000. It currently does not work when converted to Access
97, because I am using a function that was introduced in Access 2000. My solution uses
CurrentProject.path to cause the common dialog box to default to whatever folder the
database itself is saved to. Since Leojordao just indicated that he is working with
Access 2000, but he needs a solution that is compatible with Access 97, I went ahead and
sent him my sample with the caveat that it won't convert to Access 97 as written.

I suspect that the API code that you pointed Leojordao to will work fine in Access 97 too.
The sample that I sent him is more than just a code snippet to invoke a common dialog. As
I indicated last night, I believe it will be fairly easy for me to replace the call to
CurrentProject.path with something that will work in Access 97.

Tom
_________________________________


The API solution I pointed to isn't specific to any version of Access: it
will work in Access 2000.
 
The equivalent of CurrentProject.path in Access 97 is:

Left$(CurrentDb().Name, Len(CurrentDb().Name) - Len(Dir(CurrentDb().Name)))

FWIW, have you looked at the code at
http://www.mvps.org/access/api/api0001.htm? It's a little more than just a
code snippet.

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


Tom Wickerath said:
Doug,

My sample works fine in Access 2000. It currently does not work when converted to Access
97, because I am using a function that was introduced in Access 2000. My solution uses
CurrentProject.path to cause the common dialog box to default to whatever folder the
database itself is saved to. Since Leojordao just indicated that he is working with
Access 2000, but he needs a solution that is compatible with Access 97, I went ahead and
sent him my sample with the caveat that it won't convert to Access 97 as written.

I suspect that the API code that you pointed Leojordao to will work fine in Access 97 too.
The sample that I sent him is more than just a code snippet to invoke a common dialog. As
I indicated last night, I believe it will be fairly easy for me to replace the call to
CurrentProject.path with something that will work in Access 97.

Tom
_________________________________


The API solution I pointed to isn't specific to any version of Access: it
will work in Access 2000.
 
Hi Doug,

Thanks for providing the much easier method of obtaining the path. I had previously been
using a function I named DetermineDBPath97, which called the ParseFilePath function. Your
method is much simpler!

Tom

Function DetermineDBPath97() As String
' Used to determine the folder that this database is saved in.
' This function relies on the ParseFilePath function shown below.

On Error GoTo ProcError
Dim strFilePath As String

strFilePath = CurrentDb.Name
DetermineDBPath97 = ParseFilePath(strFilePath)

ExitProc:
Exit Function
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
, "Error in DetermineDBPath97 procedure..."
Resume ExitProc
End Function

Function ParseFilePath(FullPathAndFileName As String)
'Given a fully qualified path and filename, ParseFilePath returns only the file path.
On Error GoTo ProcError

Dim i As Integer
Dim LastSlash As Integer
Dim StartOfFileName As Integer

For i = 1 To Len(FullPathAndFileName)
LastSlash = InStr(i, FullPathAndFileName, "\")

If LastSlash > 0 Then
StartOfFileName = LastSlash
End If

If LastSlash = 0 Then
GoTo DoneParsingPath
End If

Next i

DoneParsingPath:
ParseFilePath = Left$(FullPathAndFileName, StartOfFileName - 1)

ExitProc:
Exit Function
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
, "Error in ParseFilePath procedure..."
Resume ExitProc
End Function

________________________________________


The equivalent of CurrentProject.path in Access 97 is:

Left$(CurrentDb().Name, Len(CurrentDb().Name) - Len(Dir(CurrentDb().Name)))

FWIW, have you looked at the code at
http://www.mvps.org/access/api/api0001.htm? It's a little more than just a
code snippet.

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


Tom Wickerath said:
Doug,

My sample works fine in Access 2000. It currently does not work when converted to Access
97, because I am using a function that was introduced in Access 2000. My solution uses
CurrentProject.path to cause the common dialog box to default to whatever folder the
database itself is saved to. Since Leojordao just indicated that he is working with
Access 2000, but he needs a solution that is compatible with Access 97, I went ahead and
sent him my sample with the caveat that it won't convert to Access 97 as written.

I suspect that the API code that you pointed Leojordao to will work fine in Access 97 too.
The sample that I sent him is more than just a code snippet to invoke a common dialog. As
I indicated last night, I believe it will be fairly easy for me to replace the call to
CurrentProject.path with something that will work in Access 97.

Tom
_________________________________


The API solution I pointed to isn't specific to any version of Access: it
will work in Access 2000.
 
Back
Top