G
Guest
Can someone help in retrieving data from the Access 2000 using VBA.
I have the following code where on OpenRecordset I receive:
Error # 424: Object required
Option Compare Database
Dim valYear As String
Dim valMonth As String
Dim sMonth As Double
Sub MonthYear()
On Error GoTo MonthYear_Err:
Dim db As Database
Dim rst As Recordset
Dim sql As String
sql = "Select tblMonth.fldPoints " _
& "From tblMonth Where tblMonth.fldMonth = '" & valMonth & "'"
MsgBox sql
Set db = CurrentDb()
Set rst = qry.OpenRecordset(sql, dbOpenSnapshot)
If Not rst.EOF Then
sMonth = rst!Month
End If
sMonth = rst!fldMonth
MonthYear_Exit:
Set db = Nothing
Set rst = Nothing
Exit Sub
MonthYear_Err:
MsgBox "Error # " & Err.Number & ": " & Err.Description
Resume MonthYear_Exit
End Sub
Thanks in advance,
I have the following code where on OpenRecordset I receive:
Error # 424: Object required
Option Compare Database
Dim valYear As String
Dim valMonth As String
Dim sMonth As Double
Sub MonthYear()
On Error GoTo MonthYear_Err:
Dim db As Database
Dim rst As Recordset
Dim sql As String
sql = "Select tblMonth.fldPoints " _
& "From tblMonth Where tblMonth.fldMonth = '" & valMonth & "'"
MsgBox sql
Set db = CurrentDb()
Set rst = qry.OpenRecordset(sql, dbOpenSnapshot)
If Not rst.EOF Then
sMonth = rst!Month
End If
sMonth = rst!fldMonth
MonthYear_Exit:
Set db = Nothing
Set rst = Nothing
Exit Sub
MonthYear_Err:
MsgBox "Error # " & Err.Number & ": " & Err.Description
Resume MonthYear_Exit
End Sub
Thanks in advance,