473,395 Members | 1,652 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Find a record when Form opens

Hello all

My code used to work, but now its not working any more. What I am
trying to do is find the current user when a forms open. This is the
code that used to work:

If faq_IsUserInGroup("Admins", CurrentUser) Then
Me.RecordSource = "SELECT * FROM Employees"
DoCmd.FindRecord (CurrentUser)
<----------------------------------------------------
Me.Label50.Visible = True
Me.ViewReports.Visible = True
Me.AddDeleteExpenseTypes.Visible = True
Me.Label48.Visible = True
Me.Line69.Visible = True
Me.Label52.Visible = True
Me.Line72.Visible = True
Else
Me.Label50.Visible = False
Me.ViewReports.Visible = False
Me.AddDeleteExpenseTypes.Visible = False
Me.NavigationButtons = False
Me.Label48.Visible = False
Me.Line69.Visible = False
Me.Label52.Visible = False
Me.Line72.Visible = False
Me.manageu.Visible = False
End If

Basically is a user is under the Admins group he can see all the
records/users...otherwise the rest of the user groups can only see his
records.

DoCmd.FindRecord (CurrentUser) suppose to find the currentuser, so the
form will open showing his information, but its NOT working

Any ideas???

Aug 31 '06 #1
8 1658
what's the problem with passing the filter in the Open event of the
form? You can pass a valid where clause, in your case
[SomeField]=CurrentUser

Aug 31 '06 #2

pi********@hotmail.com wrote:
what's the problem with passing the filter in the Open event of the
form? You can pass a valid where clause, in your case
[SomeField]=CurrentUser
I dont quite understand what you mean. I dont want only "some field" I
want all the form to display only the information of the currentuser.

Can you explain me a lil bit more please, thanks

Aug 31 '06 #3

Ok, I see what you mean. But I cant apply that technique in here. The
form has a subform. I want to be able to display only the record from
the currentuser, in the form so I will automatically show the
information of that currentuser in the subform.

Any other ideas

Aug 31 '06 #4
Public Sub OpenFilteredForm()
DoCmd.OpenForm "frmMyFormName", acNormal, ,
"[UserNameFieldFromSourceTable]=" & CurrentUser
End Sub

Aug 31 '06 #5
Code like this should work:

If faq_IsUserInGroup("Admins", CurrentUser) Then
Me.RecordSource = "SELECT * FROM Employees"
else
Me.RecordSource = "SELECT * FROM Employees WHERE
Employees.Username=" & CurrentUser
End If

then when someone opens the form, the admins will see all the records,
but the other employees will only see their records. The catch is that
you have to record the user's name somewhere in the record.

Filtering the subform depends on the main form/subform
LinkChild/LinkMaster properties. But you could set the rowsource of
the subform to:
SELECT...FROM...WHERE Employee.Username=CurrentUser

Aug 31 '06 #6

What about... forget all I said. And

You create a new User so he can use the database. This user has Admin
rights.
He logon to the application, and the form (to enter his information,
name, address, etc.) needs to be blank when it loads (because he is a
new user), he enter all his info and save his info
BUT
if the user already exist....he logon to the application and the form
(with the information) should load with his information (because he is
an existing user, and he already complete this step). Even if there are
20 users that have already completed the information form...the user
that logon should see HIS information when the form loads, in other
words I dont want to be using the navigation buttons to find a
particular user....

How would you do that....again forget all that I said in the previous
post, I just want to see if there is a better way to do this, because
the way i am trying to do it its not working quite well

Everything is working good but imagine if there are 50 users within the
application. The president logon to complete an expense report (thats
what this application is about) he does not want to be using the
navigation buttons to find his "profile" he just want to see directly
his information when the application loads, so he can fill his expense
report and print it w/o losing much time, do you understand what I
mean?

Thank you in advance

Aug 31 '06 #7

erick-flores wrote:
What about... forget all I said. And

You create a new User so he can use the database. This user has Admin
rights.
BAD design. That means that user can modify/delete ANYTHING in your
database, and completely wreck it. (Well, unless it's an MDE).
He logon to the application, and the form (to enter his information,
name, address, etc.) needs to be blank when it loads (because he is a
new user), he enter all his info and save his info
So base all the forms on queries, and filter for =CurrentUser() Then
the user can't see anything else.
Everything is working good but imagine if there are 50 users within the
application. The president logon to complete an expense report (thats
what this application is about) he does not want to be using the
navigation buttons to find his "profile" he just want to see directly
his information when the application loads, so he can fill his expense
report and print it w/o losing much time, do you understand what I
mean?
If you have the president's user account as a member of different
groups, you can give him different rights, and use a function or
whatever you want in the splash screen or whatever to determine what
objects the current user can use. If you got a copy of the form in the
Developer Handbook that mimics an Access db with all the containers
(for queries etc), then you could totally control what the users could
do, and it would look just like a normal Access DB, but they can only
use what you say they can.

This sort of makes sense. So the president will have different rights
than other users, because he is a member of more groups than other
users. So he'll have more menu choices. A new user? You would have
to create an account for this person to use the database if it's
secured. Or is it not? If it isn't the users/groups is worthless.
If you wanted to store all the name/address stuff in the database, you
could use CurrentUser to filter what the person sees in the db.

Aug 31 '06 #8
The user was just an example. I do have different groups to access the
DB. Some can look at all the users other can look only at their info.
Groups have different permissions to tables/forms/reports and all that.
Thats all taking care of.

I will check tomorrow to see if I can fix my problem

Thank you

Sep 1 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Nothing | last post by:
I have a form that opens. On this form there is information along with a button that opens a payment form. The payment form opens and I enter a payment type, cash check or charge, a payment...
1
by: Mike | last post by:
I have a form that certain information on it. On this form there is a button that opens a payment form. When the payment form opens I enter a payment type, check cash charge, payment number,...
15
by: Steve | last post by:
I have a form with about 25 fields. In the BeforeUpdate event of the form, I have code that sets the default value of each field to its current value. For a new record, I can put the focus in any...
1
by: Just Me | last post by:
Table A contains a list of colors (example red, blue, green) Table B contains a variation of the colors in Table A (example light-red, medium-red, dark-red) To add a color variation to Table...
3
by: Randy | last post by:
I have been able to set up a Find Record Button on my switchboard to take me to a form with the correct case number by using a parameter query and macro. When I try to run the Find Record button...
6
by: dbuchanan | last post by:
VS2005 I've been reading all the help I can on the topic (MSDN, other) but I can't make sense of this. Desired behavior; The user is to choose from the displayed list of the databound combobox...
0
by: Kaur | last post by:
Hi, I am having problem trying to go to same record when I close 3rd form. I have a form called frmDepartment. This form has a list box that displays all the departments. Clicking on one of the...
10
by: dstorms | last post by:
Hi, I'm trying to create a button on a form that: 1. Takes the ComputerID from the form linked to Table 1, 2. Checks Table 2 for a matching ComputerID, and 3. Opens the query qryEditData, and...
22
by: paul | last post by:
A crude, unlikely scenario just so I can get my head around this: Split DB; front end back end. Each user has the FE locally the BE is stored on a server. 1. UserA opens customerA's record and...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.