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!

Check this Code

Status
Not open for further replies.

Rasheed Shaik

Programmer
Mar 20, 2011
23
SA
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then

Set fd = CreateObject("Adodb.connection")
fd.Provider = "Microsoft.jet.oledb.4.0"
fd.Open App.Path & "\Users.mdb", "endromida"
'fd.Open "\\mika\medrar\Medrar.mdb","endromida"
Set Fs = New ADODB.recordset
Fs.Open "Select role from Useraccount where username = '" & Text1.Text & "'", fd, adOpenKeyset, adLockOptimistic
While Not Fs.EOF
Text3.Txt = .Fields!role

Fs.MoveNext
Wend
Fs.Close
Set Fs = Nothing

Call cmdOK_Click
End If
End Sub
**********
Invalid Reference of Role
 
I don't know about Access, but I know ROLE is a reserved keyword in SQL Server, so it may also be a reserved keyword in Access too. I would encourage you to change the name of the column if you can (without impacting too much code). Otherwise, you could try this:

Code:
Fs.Open "Select [!][[/!]role[!]][/!] from Useraccount where username = '" & Text1.Text & "'", fd, adOpenKeyset, adLockOptimistic

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Text3.Txt = .Fields!role change to

Text3.Txt = FS.Fields!role

David Paulson

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top