Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem opening a recordset

Status
Not open for further replies.

kriehn16

Technical User
Jul 1, 2008
18
US
I am trying to check what type of authorization a user has (which I get from my database) and then based on their
authorization I will make a certain button either visible or not.
However when I am trying to check the database I get the error:
Run-time error '-2417467259(80004005)':
Method 'Open' of object '_Recordset' failed
I don't know what I am doing wrong. I have pasted my code below. Any help would be greatly appreciated.

Sub Authorize()

Dim stSQL As String
Dim tester As Outlook.Application

Dim UserName As String
Dim User As String

Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Dim cn As ADODB.Connection
Set cn = New ADODB.Connection
cn.Provider = "Microsoft.Jet.OLEDB.4.0"
cn.Open stdbName

Set tester = ThisOutlookSession

UserName = tester.Session.CurrentUser.Name

stSQL = "SELECT authorization FROM UserDataTable WHERE name = '" & UserName & "'"

rs.Open stSQL, cn

If rs("authorization") = 0 Then
UserForm6.CommandButton1.Visible = True
Else
UserForm6.CommandButton1.Visible = False
End If
rs.Close

End Sub


-joker16
 
cn.Open stdbName

What is the value of stdbName
 
I set stdbName in another module. It is the path to my database.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top