Hi
i have a problem with some database code:
Im using ADO and a Microsoft Access db, this specific code is meant to check if a User has the yes/no field "STAccess" ticked - if so, the option button "optStat" becomes visible, and if not, the label "lblNoSTAccess" becomes visible.
NOW HERE's THE PROBLEM:
I just dont know what i've done to my code! one minute it was working fine, and then a little while later i get "Run Time Error '3021': Either BOF or EOF is true, or the current record has been deleted. Requested operation requires a current record."
When i check the db, everything is in order, WHAT COULD HAVE HAPPENED?!!!?!?!
The code is below, and the line of code which causes the error is in red:
Private Sub Form_Load()
Open App.Path & "\login.riw" For Input As #1
lblStatID.Caption = Input(LOF(1), 1)
Close #1
Dim sql As String
Dim dbconnection As New ADODB.Connection
Dim rs As New ADODB.Recordset
'Open the database
dbconnection.Provider = "Microsoft.Jet.OLEDB.4.0"
dbconnection.Open App.Path & "\RadioiW.mdb"
'Prepare the recordset
rs.ActiveConnection = dbconnection
rs.CursorType = adUseStatic
rs.CursorLocation = adUseClient
sql = "SELECT * FROM UserAccess WHERE StationID='" & lblStatID.Caption & "'"
rs.Open sql
If rs("STAccess" Then
optStat.Visible = True
lblNoSTAccess.Visible = False
Else
optStat.Visible = False
lblNoSTAccess.Visible = True
End If
End Sub
Im actually stuck! Please help me!
thanks
~nick
i have a problem with some database code:
Im using ADO and a Microsoft Access db, this specific code is meant to check if a User has the yes/no field "STAccess" ticked - if so, the option button "optStat" becomes visible, and if not, the label "lblNoSTAccess" becomes visible.
NOW HERE's THE PROBLEM:
I just dont know what i've done to my code! one minute it was working fine, and then a little while later i get "Run Time Error '3021': Either BOF or EOF is true, or the current record has been deleted. Requested operation requires a current record."
When i check the db, everything is in order, WHAT COULD HAVE HAPPENED?!!!?!?!
The code is below, and the line of code which causes the error is in red:
Private Sub Form_Load()
Open App.Path & "\login.riw" For Input As #1
lblStatID.Caption = Input(LOF(1), 1)
Close #1
Dim sql As String
Dim dbconnection As New ADODB.Connection
Dim rs As New ADODB.Recordset
'Open the database
dbconnection.Provider = "Microsoft.Jet.OLEDB.4.0"
dbconnection.Open App.Path & "\RadioiW.mdb"
'Prepare the recordset
rs.ActiveConnection = dbconnection
rs.CursorType = adUseStatic
rs.CursorLocation = adUseClient
sql = "SELECT * FROM UserAccess WHERE StationID='" & lblStatID.Caption & "'"
rs.Open sql
If rs("STAccess" Then
optStat.Visible = True
lblNoSTAccess.Visible = False
Else
optStat.Visible = False
lblNoSTAccess.Visible = True
End If
End Sub
Im actually stuck! Please help me!
thanks
~nick