Retrieve a value from a value Listbox and use in TransferText comm

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,

I have a popup form that allows a user to go through the file dialog browse
window, or whatever you call it, to locate a file for import. The path and
filename are stored as one long string in a listbox.

How do I retrieve this value to use in a Transfertext command? I am trying
to use the listbox value as a string in my transfertext command so that any
file in any directory can be used. Of course, I'm not sure exactly how to do
this either.

My listbox is called Filelist.

Here is my Transfertext command:

DoCmd.TransferText acImportFixed, "DMAImportDataImportSpecification",
"DMAImportData", "L:\STW\DAImportData.Txt"

I would like to pull that value from the Listbox , and put in a variable
called File_Location_Name so it can be used as part of the Transfertext
command where I now have the "L:\STW\DAImportData.txt".

How do I declare File_Location_Name is it an object or string? I assumed
string.

I thought I could pull out the FileList value like this, but it doesn't
appear to work:

File_Location_Name = Forms!File_Prompt_Form!FileList(0)

I want to use the value from the listbox in my Transfertext command where
the "L:\STW\DAImportData.Txt" is being used since the directory path and
filename will vary.

Any help you can give will greatly be appreciated!

Thanks
 
Try ...
DoCmd.TransferText acImportFixed, "DMAImportDataImportSpecification",
"DMAImportData", Filelist.list(Filelist.listindex)

But test it first to see if a line has been highlighted with...

if Filelist.listindex > -1 then

DoCmd.TransferText acImportFixed, "DMAImportDataImportSpecification",
"DMAImportData", Filelist.list(Filelist.listindex)

end if
 
KmhComputer said:
I have a popup form that allows a user to go through the file dialog browse
window, or whatever you call it, to locate a file for import. The path and
filename are stored as one long string in a listbox.

How do I retrieve this value to use in a Transfertext command? I am trying
to use the listbox value as a string in my transfertext command so that any
file in any directory can be used. Of course, I'm not sure exactly how to do
this either.

My listbox is called Filelist.

Here is my Transfertext command:

DoCmd.TransferText acImportFixed, "DMAImportDataImportSpecification",
"DMAImportData", "L:\STW\DAImportData.Txt"

I would like to pull that value from the Listbox , and put in a variable
called File_Location_Name so it can be used as part of the Transfertext
command where I now have the "L:\STW\DAImportData.txt".

How do I declare File_Location_Name is it an object or string? I assumed
string.


If the user selects an item in the list and if the list box
is Single Select, then use:

Dim File_Location_Name As String
File_Location_Name = Me.Filelist
DoCmd.TransferText acImportFixed, _
"DMAImportDataImportSpecification", _
"DMAImportData", _
File_Location_Name

If any of my assumptions are not valid, please explain.
 
Thanks Marshall and Chris,

You guys lead me to a working solution. This what I now and it is working
perfectly.


Dim File_Location_Name As String
File_Location_Name = FileList.ItemData(varFile)
DoCmd.TransferText acImportFixed, _
"DMAImportDataImportSpecification", _
"DMAImportData", _
File_Location_Name


Thanks again! On my way to getting this project done!

Kathy
 
Back
Top