RE: New Login questiion
- From: Bob Quintal <rquintal@xxxxxxxxxxxxx>
- Date: 08 Dec 2007 21:51:02 GMT
=?Utf-8?B?Sm9obiBQZXR0eQ==?= <JohnPetty@xxxxxxxxxxxxxxxxxxxxxxxxx>
wrote in news:440A0A02-7204-456B-A781-A36C0FCAAE69@xxxxxxxxxxxxx:
Visual Basic is not SQL, they are two different languages.
"John Petty" wrote:
I have created a login form in which the user has to type in
their company ID and password to allow access to database
manipulation (other than readonly). This part works great. But
I am having an issue with a certain textbox_afterupdate. After
the user types in their ID, I want to have a "Name" textbox
verify that it is indeed the intended user (or if not found, note
it in a msgbox and allow to create new as needed).
The problem is that I don't quite know how to pull the data from
a table record.
Any help would be appreciated.
Thanks in advance,
John Petty
Sorry, Here's the code.
Private Sub tbBadge_AfterUpdate()
If IsNull(Me.tbBadge) Or Me.tbBadge = "" Then
MsgBox "You must enter a Badge Number", vbOKOnly, "Required
Data" Me.tbBadge.SetFocus
Exit Sub
Else
SELECT DISTINCT FirstName, LastName
FROM tblEmp
WHERE .BadgeNumber = Me.tbBadge.Value
Me.tbName.Value = tblEmp.FirstName & " " & tblEmp.LastName
Me.tbPassword.SetFocus
End Sub
Also, I get a "Case" error on the SELECT Statement.. ???
Modify your code as follows.
Private Sub tbBadge_AfterUpdate()
Dim strSQL as string
dim RS as recordset
If IsNull(Me.tbBadge) Or Me.tbBadge = "" Then
MsgBox "You must enter a Badge Number", vbOKOnly, "Required
Data"
Me.tbBadge.SetFocus
Exit Sub
Else
'Put the SQL into a VB variable
strSQL = "SELECT DISTINCT FirstName, LastName " _
& "FROM tblEmp " _
& "WHERE .BadgeNumber = " & Me.tbBadge.Value
'now open the recordset
set RS = currentdb.openrecordset(strSQL)
'you need to test that the recordset returns a value.
if RS.EOF
'do whatever if there is no name.
else
Me.tbName.Value = RS!FirstName & " " & RS!LastName
end if
RS.Close
Me.tbPassword.SetFocus
End Sub
--
Bob Quintal
PA is y I've altered my email address.
--
Posted via a free Usenet account from http://www.teranews.com
.
- Follow-Ups:
- RE: New Login questiion
- From: John Petty
- RE: New Login questiion
- References:
- New Login questiion
- From: John Petty
- New Login questiion
- Prev by Date: New Login questiion
- Next by Date: Re: Check if Form is Open
- Previous by thread: New Login questiion
- Next by thread: RE: New Login questiion
- Index(es):
Relevant Pages
|