Getting data from a folder when I only know part of the folder name

  • Thread starter Thread starter Bill H
  • Start date Start date
B

Bill H

I need to import data into a database from a folder on
the network. The problem is that I can not create the
name of the folder from data that exist in the database.

I can however create part of the name of the folder from
the database.

Example:
The file I want to import is in a Folder name is "46a
2556 bt105"

This name is created by a tester and a new folder with a
new name is created for each experiment. The experiment
name is 2556 and I can get that from the database.

How do I create the path with only the experimet name?

Bill
 
Hi Bill,

Use something like

Dim strFolderName As String
Dim strExperimentName As String

strExperimentName = Me.txtExperimentName.Value
'or whatever is needed to get the experiment name
'from the database
strFolderName = "46a " & strExperimentName & " bt105"
 
On second thoughts, are you trying to search for a folder when you only
know a fragment of its name? If so, use something like

Dim strPath1 As String
Dim strFolder As String
Dim strExperimentName As String

strPath1 = "D:\Folder"
strExperimentName = Me.txtExperimentName.Value
'or whatever is needed to get the experiment name
'from the database

strFolder = Dir(strPath1 & "\*.*", vbDirectory)
Do While Len(strFolder) > 0
If strFolder Like "*" & strExperimentName & "*" Then
'folder found
strFolder = strPath1 & "\" & strFolder
Exit Do
End If
strFolder = Dir()
Loop
If Len(strFolder) = 0 Then
MsgBox "Sorry, couldn't find folder with name " _
& "containing " & strExperimentName
End If
 
I know what the experiment is, what I don't know is the
other data:
xxx"experiment"xxx
The next folder name could be
ccc"experiment"ccc

Each experiment will have a different folder name.
-----Original Message-----
Hi Bill,

Use something like

Dim strFolderName As String
Dim strExperimentName As String

strExperimentName = Me.txtExperimentName.Value
'or whatever is needed to get the experiment name
'from the database
strFolderName = "46a " & strExperimentName & " bt105"



I need to import data into a database from a folder on
the network. The problem is that I can not create the
name of the folder from data that exist in the database.

I can however create part of the name of the folder from
the database.

Example:
The file I want to import is in a Folder name is "46a
2556 bt105"

This name is created by a tester and a new folder with a
new name is created for each experiment. The experiment
name is 2556 and I can get that from the database.

How do I create the path with only the experimet name?

Bill

--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.
.
 
Back
Top