I'm having problems getting a simple application to run on an Access 2.0 database. It works wonderfully with Access 2002. I was wondering if anyone can tell me why the following code doesn't work:
My thinking is either the SQL query isn't the correct dialect or the recordset.open statement has a problem. Thanks for any help.
Code:
Public Conn1 As ADODB.Connection
Public rstNTE As ADODB.Recordset
Public cmdNTE As ADODB.Command
Public Sub OpenX()
Dim strConn As String
Set Conn1 = New ADODB.Connection
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\My Documents\VBProjects\Tony2.mdb"
Conn1.Open strConn
Set rstNTE = New ADODB.Recordset
Set cmdNTE = New ADODB.Command
End Sub
Private Sub Form_Load()
Dim strNum As String
'Call public subroutine to establish database connection
OpenX
cmdNTE.ActiveConnection = Conn1
'Get pay locations
strNum = "SELECT DISTINCT P_Loc FROM ROSTER;"
cmdNTE.CommandText = strNum
rstNTE.Open cmdNTE, , adOpenForwardOnly, adLockReadOnly, adCmdText
Do Until rstNTE.EOF = True
If rstNTE!P_Loc > 100 And rstNTE!P_Loc < 400 Then
lstPayLoc.AddItem rstNTE!P_Loc
End If
rstNTE.MoveNext
Loop
rstNTE.Close
Conn1.Close
End Sub
My thinking is either the SQL query isn't the correct dialect or the recordset.open statement has a problem. Thanks for any help.