Johanna said:
I have a column with a mix of numbers and words.
I want to create a column with only the numbers from that column.
What is the Query-command for that? (And what does the abbreviaton stand for
- so that I can find it on Swedish version of Access as well).
Ex
Orig column New column
September 2001 2001
March -02 02
2004 2004
May
1999-05-14 19990514
You may have to define your own function to convert the strings, perhaps
a function like this:
Public Function StrNumbers(Text As String) As String
Dim intCharNum As Integer 'Index into string
Dim strNext As String 'One character from string
Dim strResult As String 'Numeric characters from string
For intCharNum = 1 To Len(Text)
'Get the next character from the string
strNext = Mid$(Text, intCharNum, 1)
'Test it to see if it's a numeric character
If InStr("0123456789", strNext) > 0 Then
'If so, include it in the result
strResult = strResult & strNext
End If
Next intCharNum
StrNumbers = strResult
End Function 'StrNumbers()
In the string "0123456789", if you also want to include other
characters, put them in here as well (any order will work).
Having defined that function, and assuming your original Table looks
like this:
Orig column
--------------
September 2001
March -02
2004
May
1999-05-14
.... you can define a Query like this:
[Q_NumericText]
SELECT Text.[Orig column],
StrNumbers([Text]![Orig column]) AS [New Column]
FROM [Text];
And this Query's output would look like this:
Orig column New Column
-------------- ----------
September 2001 2001
March -02 02
2004 2004
May
1999-05-14 19990514
-- Vincent Johns <
[email protected]>
Please feel free to quote anything I say here.