Help with Environ within Novell environment

Q

Question - Mark

I am in over my head a bit!

I am working in NOVELL environment and have developed an Access
database where I want the Novell User ID that is logged into computer
to automatically populate a Label on a form. I have the following
code, which I have muddled through with great trouble and am not even
sure it will work yet: (I am pulling the name of the employee from a
table within the database which contains SSN, EmployeeName, and
LOGINNAME)

Private Sub Form_Load()
Dim dbs As ADODB
Dim rst As Recordset

employee_login_id = Environ("s_user")

Set dbs = CurrentDb
Set rst = dbs.openrecordset("select from login_user_ids where " &
Chr(39) & LOGINNAME & Chr(39))
If rst.EOF Then
End If

socialsecuritynumber = rst!SSN

sql_string = "select * from LOGIN_USER_IDS where " & Chr(39) & SSN
& Chr(39)

End Sub

Within the form that contains the label - I have the following so far,
I don't know how to get the name into the label. I don't even
completely understand what the line with sql_string does below other
than open my form.

Private Sub AddHours_Click()
On Error GoTo Err_AddHours_Click

Dim stDocName As String

stDocName = "FrmAddRecord"
DoCmd.OpenForm stDocName, , , sql_string, acAdd

Exit_AddHours_Click:
Exit Sub

Err_AddHours_Click:
MsgBox Err.Description
Resume Exit_AddHours_Click
End Sub

Any help is greatly appreciated!!!
Mark
 
D

Douglas J. Steele

Your SQL is incorrect: you're missing the name of the field in the WHERE
clause. It needs to be:

sql_string = "select * from LOGIN_USER_IDS where LOGINNAME = " & Chr(39) &
employee_login_id & Chr(39)

I know that when we used Novell, our logon script deliberately deleted the
value of the user id from the environment variables. Using environment
variables to get the user information is somewhat dangerous: it's trivial to
reset environment variables. It's far, far safer to use the API approach
outlined in http://www.mvps.org/access/api/api0008.htm at "The Access Web"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top