Question : how to extract a number from a string containng text and special character including white space

how to extract a number from a string containng text and special character (like , . / ? etc) including white space

Answer : how to extract a number from a string containng text and special character including white space

You don't say whether the text string has any structure at all, what type of number you are looking for (interger or decimal point), neither where you need to use th extracted number (form, report, query).

However, try the following: Place the code below into a VBA module in your database. Then you can use this function in a query like this:

SELECT other_fields, ExtractFirstNumber(source_field_name) FROM table_name

This somewhat crude function will extract the first number contained within the string. It can be either integer or decimal and can be preceeded by the + or - signs.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
Private Function Min(ByVal valueA As Long, ByVal valueB As Long) As Long
    If valueA < valueB Then
        Min = valueA
      Else
        Min = valueB
    End If
End Function
 
Public Function ExtractFirstNumber(ByVal strSourceString As String) As Variant
Dim strNumber As String
Dim l As Long
Dim c As String * 1
Dim i As Long
Dim j As Long
Dim last As Long
    l = Len(strSourceString)
    For i = 1 To l
        c = Mid(strSourceString, i, 1)
        
        If IsNumeric(c) Or ((c = "." Or c = "+" Or c = "-") And IsNumeric(Mid(strSourceString, Min(i + 1, l), 1))) Then
            strNumber = c
            For j = i + 1 To Len(strSourceString)
                c = Mid(strSourceString, j, 1)
                If Not IsNumeric(strNumber & c) Then Exit For
                strNumber = strNumber & c
            Next j
            ExtractFirstNumber = CDec(strNumber)
            Exit Function
        End If
    Next i
End Function
Random Solutions  
 
programming4us programming4us