Use same data for all records

sparlaman

Registered User.
Local time
Today, 18:03
Joined
Feb 10, 2005
Messages
17
Is there a way to do the following?

The scenario: The “Animals” database contains the “AnimalsInfo” table. tblAnimalInfo contains the “AnimalType” field. User1 is always entering data for Cats. User2 is always entering data for Dogs. User3 is always entering data for Fish.

The question: What is the easiest way to automatically fill in the “AnimalType” field based on which user is entering the record?

I really don’t want to use the built in security feature for this because that entails setting up security and permissions for each user, which is not necessary in this application. :)
 
Have a table of users and animaltype, then a combobox with that table as it's control source, filtered by UserName which Access will give you.
 
Re: Pat Hartman's Response

Ok, let's say I have the table with the entry for each person along with his default animal type, any clues on what the code would be to store the values in a hidden form?

Pat Hartman
Moderator Join Date: Feb 2002
Location: Stratford,Ct USA
Posts: 16,191

Unless you use Access security, CurrentUser() is ALWAYS Admin.

You can identify people by their network names or by using the Environ() function - search for details. However, you would still need to build a table that contains an entry for each person along with his default animal type. You could then add code to your opening menu to obtain the user's id and his animal type and store them either in global variables or in a hidden form.
__________________
Bridge Players Know All the Tricks
 
Another way may be to have the following code in the OnCurrent of the form. Assuming you will only have 3 users of course. I haven't tested this :rolleyes:

Pats way is better though as it allows greater flexibility to add new users.

Code:
If IsNull(Me.AnimalType) and Environ("UserName") = "BloggsF" Then

Me.AnimalType = "Dog"

ElseIf IsNull(Me.AnimalType) and Environ("UserName") = "SmithJ" Then

Me.AnimalType = "Cat"

ElseIf IsNull(Me.AnimalType) and Environ("UserName") = "JonesG" Then

Me.AnimalType = "Fish"

Else

Exit Sub

End If

Col
 
I don't understand why you don't want to use the security. You can leave the passwords blank. You can create four user groups: dogs, cats, fish and admin.
 
Thanks!

:D Thanks for all of your suggestions. With your help and some stubborness on my part, I have figured out all of the pieces. I have created a form where the user selects his username from a combo box and types his/her password into an unbound textbox. Then the user clicks OK which runs the following code to verify the password, hide the logon form, and open the main form. So now, all I have to do is pull the data from the hidden form. Since security wasn't my main concern, this was much easier for me to do than to create users and groups and have to maintain that once this system is in production.

Private Sub btnOK_Click()
On Error GoTo Err_btnOK_Click

Dim stDocName As String
Dim stLinkCriteria As String

If Me.txtVerify = txtPassword Then
Forms!frmLogon.Visible = False
stDocName = "empSwitchboard"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox "incorrect.", vbInformation, "Incorrect"
DoCmd.GoToControl "txtPassword"
End If

Exit_btnOK_Click:
Exit Sub

Err_btnOK_Click:
MsgBox "There is a system error. Contact tech-support.", vbInformation, "System Error"
Resume Exit_btnOK_Click

End Sub
 

Users who are viewing this thread

Back
Top Bottom