Login prompt to define a user in main form (1 Viewer)

reptar

Registered User.
Local time
Today, 10:55
Joined
Jul 4, 2005
Messages
32
Hi, i have a microsoft access 97 database listing 4000+ companies. The database is being used by up to 4 people. On the main form, listed companies have a previously inputted recontact date which once the date passes the current date is flagged and listed in a query. Along side the recontact date textbox is a textbox for the person incharge of recontacting that company.

What i would like to have is some sort of Login prompt at database loadup. Then, when the main form opens, have the person who logged in displayed at the top of the form with the total amount of recontacts and possibly the amount of new recontacts for that particular day.

Is this possible?
 

pono1

Registered User.
Local time
Today, 10:55
Joined
Jun 23, 2002
Messages
1,186
This can be done but there's some work involved. Here's a rough example that uses the Windows user name for the people in charge of recontacting a company, perhaps something you can use as a starting point as you build your solution...

Code:
Option Compare Database
Option Explicit

Private UserX As String

Private Sub Form_BeforeUpdate(Cancel As Integer)
  
  ' Save the user name with the order.
  Me.myuser.Value = VBA.Environ("username")
  
End Sub

Private Sub Form_Current()
  UpdateUserOrderCount
End Sub

Private Sub Form_Open(Cancel As Integer)

  ' Get the user name.
  UserX = VBA.Environ("username")
  ' Show name on form caption.
  Me.Caption = " Logged in as " & UserX
  ' Count and show user orders.
  UpdateUserOrderCount

End Sub

Private Sub UpdateUserOrderCount()

  ' Count the orders for the user.
  Me.lblRecontacts.Caption = DCount("myuser", "orders", "myuser =" & "'" & UserX & "'")

End Sub

Regards,
Tim
 
Last edited:

Users who are viewing this thread

Top Bottom