ParaTrooper
Technical User
Access Recordsets
Hi,
I am having trouble with an access recordset. It is querying a simple table of students, who belong to particular groups (SGROUPS).
The query works fine when without the wildcard * chararcter and the LIKE clause. It returns nothing when they are in there when there is a whole load of data that it should select.
Dim studentRS As ADODB.Recordset
Set studentRS = New ADODB.Recordset
studentRS.CursorLocation = adUseClient
Dim students As String
students = "SELECT LASTNAME, FIRSTNAME, SGROUP FROM [Student detail] WHERE [Student detail].SGROUP LIKE '" & excelSGROUP & "' " '//excelSGROUP contains the group. eg D1129*
studentRS.Open students, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
If studentRS.EOF Or studentRS.BOF Then
'do nothing, empty RS
MsgBox "empty rs"
Else
'loop thru studentRS
Do Until studentRS.EOF
MsgBox studentRS!LASTNAME
Thanks for your help,
ParaTrooper
Hi,
I am having trouble with an access recordset. It is querying a simple table of students, who belong to particular groups (SGROUPS).
The query works fine when without the wildcard * chararcter and the LIKE clause. It returns nothing when they are in there when there is a whole load of data that it should select.
Dim studentRS As ADODB.Recordset
Set studentRS = New ADODB.Recordset
studentRS.CursorLocation = adUseClient
Dim students As String
students = "SELECT LASTNAME, FIRSTNAME, SGROUP FROM [Student detail] WHERE [Student detail].SGROUP LIKE '" & excelSGROUP & "' " '//excelSGROUP contains the group. eg D1129*
studentRS.Open students, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
If studentRS.EOF Or studentRS.BOF Then
'do nothing, empty RS
MsgBox "empty rs"
Else
'loop thru studentRS
Do Until studentRS.EOF
MsgBox studentRS!LASTNAME
Thanks for your help,
ParaTrooper