Import Spec / browse..

  • Thread starter Thread starter Jorge
  • Start date Start date
J

Jorge

Hi all..

I have a macro designed to import data to a specification designed.
What I'd like to do is have a popup that will allow the user to search the
filename to import.

Can this be done?

Thank-You
Jorge
 
Nick - I appreciate the response...
But I'm not sure what you directed me to? VBA - visual basic...
Is there a way in order to get the macro to begin - ask what is name of
file - click OK and then it takes off (macro)?

Jorge
 
Ok - so I found tools/convert macro to VB...

Within the VB script that appears - It has a DoCm.TransferText ....
This appears to be the selections I had dictated when I first did the macro.
In it appears to be the location of the file.. (this where I want the
program to POPUP and ask where is the file.. the guy may have it on his A:..

Any clues!
 
Hi Jorge,

I think you will have to use VBA. That is what the version
of Visual Basic is called that comes with Access from Access
97 and up. Visual Basic for Applications.

You're three quarters of the way there with the conversion
of your macro into VBA. Now go and have a look at the
TransferText method and the InputBox function in Access
Help.

Particularly look at the arguments for TransferText. In
your case what you want is the 'filename'.

Here's an example to look at which I'll then edit to get the
message:
******************
Function mcrExport()
On Error GoTo mcrExport_Err

DoCmd.TransferText acExportDelim, "", "Customers", _
"c:\nicktemp\cust.txt",
True, ""


mcrExport_Exit:
Exit Function

mcrExport_Err:
MsgBox Err.Description
Resume mcrExport_Exit

End Function
********************

Now the edited version:

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Function mcrExport()

Dim strQualFile as String 'Qualified file name
On Error GoTo mcrExport_Err

strQualFile = InputBox ("Type in target path and file
name: ", _
"Input Name")

DoCmd.TransferText acExportDelim, "", "Customers", _
strQualFile,
True, ""

mcrExport_Exit:
Exit Function

mcrExport_Err:
MsgBox Error$
Resume mcrExport_Exit

End Function
!!!!!!!!!!!!!!!!!!!!!!!!!!!

I've deliberately used InputBox rather than the browse
functions I first mentioned because it is a lot simpler to
explain and use, though less flexible.

You'll need to change bits of the code above to suit your
circumstances.

Good luck.

--
Nick Coe (UK)
AccHelp v1.01 Access Application Help File Builder
http://www.alphacos.co.uk/
Download Free Demo Copy
----
 
Thank you Nick

I had placed this code:
Hoping that it would prompt the user to browse...
I tried the code for the input box and it worked fine but the user
immediately said - "I don't wanna type bla-bla-bla.."

---------------------------------------------------------------
Function Adecco_Data_Import()
Dim strFilter As String
Dim strInputFileName As String

On Error GoTo Adecco_Data_Import_Err

strFilter = ahtAddFilterItem(strFilter, "CSV Files (*.CSV)", "*.CSV")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)

DoCmd.TransferText acImportDelim, "Adecco", "Adecco", _
strInputFileName, True, ""

Adecco_Data_Import_Exit:
Exit Function

Adecco_Data_Import_Err:
MsgBox Error$
Resume Adecco_Data_Import_Exit

End Function

It keep tellin me ahtAddFilter not defined......
Am I even close?

Jorge
 
Jorge,

Yup, you're on the right track. You're going to have to use
the code for a file browse from the MVPS web site I posted.

It may take me a while to answer this for various reasons.
If you are in a hurry I suggest you repost, otherwise I'll
post again in a while.

--
Nick Coe (UK)
AccHelp v1.01 Access Application Help File Builder
http://www.alphacos.co.uk/
Download Free Demo Copy
----
 
Do I have to place all code in same vb sheet?
or does it need to be a separate function that is called?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top