|
改成下面这样的代码就可以解决了
- Public Function gIdSeries(ByVal tblName As String) As String
- Dim rs As New ADODB.Recordset
- Dim I As Integer
- Dim strWhat As String
- Dim intID As Long
- rs.Open tblName, CurrentProject.Connection, adOpenKeyset, adLockReadOnly
- Do While Not rs.EOF
- For I = 0 To rs.Fields.Count - 1
- If Trim(rs.Fields(I)) <> "-" Then
- intID = Left(rs.Fields(I), InStr(rs.Fields(I), "-") - 1)
- If intID = 6 Then
- Debug.Print intID
- End If
- If InStr("," & strWhat, "," & intID & ",") = 0 Then
- strWhat = strWhat & intID & ","
- End If
- End If
- Next
- rs.MoveNext
- Loop
- If Len(strWhat) > 0 Then
- gIdSeries = Left(strWhat, Len(strWhat) - 1)
- End If
- rs.Close
- Set rs = Nothing
- End Function
复制代码
|
|