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!

Login Id is remebered then used in a form 2

Status
Not open for further replies.

metalboy

Technical User
Apr 1, 2004
97
GB
Hi there,

I want to be able to have a user log ont the datbase selecting thier user id from a combo box. this then opens the form that they need use (this form is the same for everyone) but in that for one of the fields already has thier log on id in it. no matter how many records they save.

make any sense????

Regards

Alex

;o)
 
Hi

Declare a global variable in a code module

dim gUserId as String

in the after update event of teh combo set the variable

gUserId = cboUserId



Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
sorry could you give me a bit more detail......????


thanks

;o)
 
Hi

Difficult, there is nothing more to it, but I will try

In the modules tab of the database window, open an existing code module or create a new one, define a variable so

Dim strUserId as String

in the after update event of the combo box wheer your user enters their user id, put code strUserId = cboUsername (where cboUsername is the name you have assigend to the combo box)

In the form which opens from the firts form in the on open event put code txtUserId = struserId where txtUserId is a textbox control on the second form

Do you need more than that ?

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
no thats execellent! thankyou very much!!!!
 
hi,

am getting the following error:

Runtime error'-2147352567(80020009)'
You cannot assign a value to this object

Any ideas

regards

Alex
 


Private Sub Form_Open(Cancel As Integer)
verifierid = strUserId <------(stops on this line)
End Sub


thanks
 
that is on the form which is opened by logon form
 
Heres another way.
create a new module and paste this in:-
=============================
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If lngX <> 0 Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = ""
End If
End Function
=================================================

save it as something like LoginId
now on your form create a new unbound text field and set its default value to
fOSUserName()

open the form in normal mode and you should see your login id in the field

Be ALERT - Your country needs Lerts
 
sorry,
the next step iss to create individual forms for your users.
name them user1PersonalForm etc.
where user1 is the users actual login ID.
in the click event of the button have
DoCmd.OpenForm fOSUserName()& "PersonalForm"

Be ALERT - Your country needs Lerts
 
thanks scottian that works like a charm


;o)
 
Hi ,

I would like to design a Logon screen instead of using Access security. I managed to design the logon screen and passowrd authentication . However , I would like the access system to store the user who logon at somewhere (may be variable) .When user print the report , the repeort field able to get the ID who logon and dsiplay name.

Any idea how to do it?

Regards
Desmond
 
Use a Global variable and a Public Function to retrieve its value.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I am not very good in programming . Could you provide a simple coding how to use Public function and return the logon name in report
 
why not try an invisible form, thats loads on start up. set to data input only and have it bound to a table (logontbl for instance) when the user logons pass the info from the logon screen to the same fields on the hidden form. you can then reference these fields whenever you like whilst the user is logged in. also you can record when the user has logged and logged out, creating a crude audit log.


"My God! It's full of stars...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top