This was posted by Pierre in another forum so copied it here for easier access and search for anyone looking for a solution.
As the subject says, this will take away the extension name from imported text files in the Item name. Really great for if you have a lot of imports.
A tip for anyone starting out, when you get to instruction # 3 "Create a new text field", when you create the new field, go down to "Type" and change it from "Yes/No" to "Text". You probably already know that.
Thanks Pierre.
- - - - - - - - -
1- In Visual Basic Editor, tab User code or This database, enter:
Function FileNameNoExt(FName)
dim i, s
s = FName
i = instrrev(fname,".")
if i > 0 then
s = left(fname,i-1)
end if
FilenameNoExt=s
End Function
2- Click Validate Code, Save and Close
3- Create a new text field, called TempTxt. In Equations > Row Equation, enter =FileNameNoExt([Item])
4- DO NOT click on the Refresh button on the right of the equation box, as this would apply the equation to all items
5- Add the field TempTxt to your grid
6- Select 1 or more imported file items, those which you want to rename the item to remove the extension
7- Do Edit > Touch. This basically does as it you modified the item and will trigger the row equation
8- The TempTxt field should now be filled with just the file name (no extension)
9- Repeat for all such items (select all these items and do Edit > Touch). All items should automatically have a value for the TempTxt field
10- When you're happy with the result, you can copy the cell values from the TempTxt column to the Item column
(Select all text, Edit > Copy, Select cells in the Item's column, Edit > Paste)
(Select all text, Edit > Copy, Select cells in the Item's column, Edit > Paste)
11- Delete the field TempTxt or at least, turn off its row equation
Voilà !
Pierre_Admin
IQ Designer