|
本帖最后由 Henry D. Sy 于 2009-5-16 10:49 编辑
'---------------------------------------------------------------------------------------
' Procedure : gString
' DateTime : 2009/5/15 23:21
' Author : Henry D. Sy
' Purpose :
'---------------------------------------------------------------------------------------
'
Public Function gString(ByVal strTblName As String, ByVal FldName As String, FldVal As String) As String
Dim rs As New ADODB.Recordset
Dim strSQL As String
Dim strCarNo As String, str As String
Dim i As Integer, j As Integer
On Error GoTo gString_Error
strSQL = "select distinct " & FldName & " from " & strTblName & " where " & FldName & "='" & FldVal & "'"
With rs
.Open strSQL, CurrentProject.Connection, adOpenKeyset, adLockReadOnly
strCarNo = .Fields(0)
For i = 1 To Len(strCarNo)
str = Mid(strCarNo, i, 1)
j = j + 1
If IsNumeric(str) Then
Exit For
End If
Next
.Close
End With
gString = Mid(strCarNo, j)
Set rs = Nothing
On Error GoTo 0
Exit Function
gString_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ")"
End Function
查询中直接调用
SELECT 表1.编号, 表1.车版, gString("表1","车版",[车版]) AS AAA
FROM 表1;
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|