您可能可以使用用戶定義的功能來實現此功能。像這樣的東西可能會有所幫助。將代碼複製到標準模塊中,然後編譯它。
Public Function getFirstName(inputStr As String) As String
'********************
'Code Courtesy of
' Paul Eugin
'********************
Dim tmpArr() As String, retStr As String
Dim iCtr As Integer, charPos As Integer
'Strip the Input String to an Array.
tmpArr = Split(inputStr, ",")
'Loop through the Array
For iCtr = 0 To UBound(tmpArr)
'Find the position of the SPACE character
charPos = InStr(Trim(tmpArr(iCtr)), " ")
'If the position is not found, return the whole string
If charPos = 0 Then charPos = Len(tmpArr(iCtr))
'Append the result String
retStr = retStr & Trim(Left(tmpArr(iCtr), charPos)) & ", "
Next
'Finally return the actual generated String
getFirstName = Left(retStr, Len(retStr) - 2)
End Function
要在即時窗口中使用它,把它作爲,
? getFirstName("Wilson, Larry")
Wilson, Larry
? getFirstName("Clooney, George Timothy")
Clooney, George
這也可以在查詢中使用。
SELECT
yourTableName.yourFieldName,
getFirstName(yourTableName.yourFieldName) As NewFieldName
FROM
yourTableName;
我對訪問和尋求幫助很新。很抱歉地告訴我,我嘗試了很多,沒有任何幫助。 'SELECT LEFT(UserName,INSTRREV(UserName,「」))' – Michael 2014-09-25 12:57:53
您正在使用哪個版本的Access?使用這樣的標籤是沒用的,最好定義與您的環境完全匹配的標籤 – 2014-09-25 13:00:12
我正在使用access 2007。 – Michael 2014-09-25 13:05:33