MartyConnelly
martyconnelly at shaw.ca
Mon Oct 16 21:00:48 CDT 2006
assuming a file name is "test1_MFormName.txt" and you want to strip out the Access Form name MFormname Mid(strTemp, InStr(1, strTemp, "_", vbTextCompare) + 1) Your function is returning the file extension as well "MFormName.txt" Add a function like this to remove any extension I 'll let you work it out for InStrRev which is easier Function fURLWithoutExtension(strFile As String) As String 'return filename minus extension Dim j As Long Dim strURL 'could use InStrRev but not available in 97 strURL = fstrReverse(strFile) 'Find the url name without extension 'Find the first occurance of the '.' in the FileName string j = InStr(1, strURL, ".", vbTextCompare) If j = 0 Then 'URL name does not contain a '.' character fURLWithoutExtension = strURL Else 'URL name does contain the '.' character fURLWithoutExtension = Right$(strURL, Len(strURL) - j) End If 'switch reverse back fURLWithoutExtension = fstrReverse(fURLWithoutExtension) End Function Function fstrReverse(strInput As String) As String ' REVERSES A STRING, SPACES & ALL for Access 97 Dim i As Integer For i = Len(strInput) To 1 Step -1 fstrReverse = fstrReverse & Mid(strInput, i, 1) Next i End Function Martin Reid wrote: >anyone see anyhting wrong with this. Keeps erroring out at the Case Form. > >Here is a form name Form_Customer Orders Subform.txt > >Public Sub loadup() >On Error GoTo Err_loadup >Dim strTemp As String >strTemp = Dir("C:\Forms\*.txt") >Do Until strTemp = "" > Select Case UCase(Left(strTemp, 4)) > Case "FORM" > Application.LoadFromText acForm, Mid(strTemp, InStr(1, strTemp, "_", vbTextCompare) + 1), "C:\forms\" & strTemp > Case "REPO" > Application.LoadFromText acReport, "test", "C:\Forms\" & strTemp > End Select > strTemp = Dir >Loop >Exit_loadup: >Exit Sub >Err_loadup: > MsgBox Err.Description, Err.Number > Resume Exit_loadup > Resume 0 '.FOR TROUBLESHOOTING >End Sub > > >Martin WP Reid >Training and Assessment Unit >Riddle Hall >Belfast > >tel: 02890 974477 > > > >------------------------------------------------------------------------ > >No virus found in this incoming message. >Checked by AVG Free Edition. >Version: 7.1.408 / Virus Database: 268.13.4/476 - Release Date: 14/10/2006 > > -- Marty Connelly Victoria, B.C. Canada