Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / May 2007

Tip: Looking for answers? Try searching our database.

ignoring numbers and brackets

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Anna Busby - 15 May 2007 16:53 GMT
I have a question that relates to setting up a database for a laboratory
chemicals list.  I've managed to import all the values from an Excel
spreadsheet but when I go to sort them I find that the program takes me too
literally as some of the chemical names start with a bracket or number.  For
example:
1,3 Propanedithiol
which should come under P is near the top.

Can anyone help me please?
workATaccess - 15 May 2007 17:42 GMT
How about setting up a separate field for the pre-fixes (the 1,3 or brackets)?

> I have a question that relates to setting up a database for a laboratory
> chemicals list.  I've managed to import all the values from an Excel
[quoted text clipped - 5 lines]
>
> Can anyone help me please?
workATaccess - 15 May 2007 17:49 GMT
Set up the separate field in the access table as "prefixes", the have the
"main chemical name" in its own field.  This way when you export you will be
able to sort using the the "main chemical name" field.
Good luck.

> I have a question that relates to setting up a database for a laboratory
> chemicals list.  I've managed to import all the values from an Excel
[quoted text clipped - 5 lines]
>
> Can anyone help me please?
Kerry - 15 May 2007 17:53 GMT
Hi Anna,

You could create a function that ignores what you want to ignore, then
sort by that.  For example:

Public Function IgnoreNumbersBrackets(InititalValue) As Variant
   Dim intPos As Integer
   Dim strTemp As String
   Let IgnoreNumbersBrackets = Null
   If IsNull(InititalValue) Then Exit Function
   If Len(InititalValue) = 0 Then
       Let IgnoreNumbersBrackets = InititalValue
   End If
   Let strTemp = InititalValue
CheckFirstChar:
   Select Case Left(strTemp, 1)
       Case "0" To "9", "[", "]", " ",","
           Let strTemp = Mid(strTemp, 2)
           GoTo CheckFirstChar
   End Select
   Let IgnoreNumbersBrackets = strTemp
End Function

On May 15, 11:53 am, Anna Busby <Anna B...@discussions.microsoft.com>
wrote:
> I have a question that relates to setting up a database for a laboratory
> chemicals list.  I've managed to import all the values from an Excel
[quoted text clipped - 5 lines]
>
> Can anyone help me please?
Ken Sheridan - 15 May 2007 17:59 GMT
Add the following function to a standard module:

Public Function ChemName(varChemName As Variant) As String

   Dim i As Integer, n As Integer
   Dim strChemName As String
   
   If Not IsNull(varChemName) Then
       strChemName = varChemName
       n = Len(strChemName)
       ' step through name and remove characters
       ' until first alphabetic character is encountered
       For i = 1 To n
           Select Case Asc(Mid$(strChemName, 1, 1))
               Case 65 To 90    ' upper case letter
               Exit For
               Case 97 To 122    ' lower case letter
               Exit For
               Case Else
               ' remove character
               strChemName = Mid$(strChemName, 2)
           End Select
       Next i
   End If
   
   ChemName = strChemName
       
End Function

You can then call it, passing the chemical names as imported into the
function as its argument, ChemName([Chemical Name])

You can use it in whatever way is most appropriate, e.g.

1.  Permanently remove the leading non-alphabetic characters by means of an
update query:

UPDATE [YourTable]
SET [Chemical Name] = ChemName([Chemical Name]);

2.  View the full name as imported but sort by the name trimmed of the
non-alphabetic characters:

SELECT [Chemical Name]
FROM [YourTable]
ORDER BY ChemName([Chemical Name]);

3.  Keep the full name as imported in the table but view it and sort it
trimmed of the non-alphabetic characters:

SELECT ChemName([Chemical Name]) AS [Trimmed Name]
FROM [YourTable]
ORDER BY ChemName([Chemical Name]);

Ken Sheridan
Stafford, England

> I have a question that relates to setting up a database for a laboratory
> chemicals list.  I've managed to import all the values from an Excel
[quoted text clipped - 5 lines]
>
> Can anyone help me please?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.