473,848 Members | 1,568 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_IsUserInGro up("Admins", CurrentUser) Then
Me.RecordSource = "SELECT * FROM Employees"
DoCmd.FindRecor d (CurrentUser)
<----------------------------------------------------
Me.Label50.Visi ble = True
Me.ViewReports. Visible = True
Me.AddDeleteExp enseTypes.Visib le = True
Me.Label48.Visi ble = True
Me.Line69.Visib le = True
Me.Label52.Visi ble = True
Me.Line72.Visib le = True
Else
Me.Label50.Visi ble = False
Me.ViewReports. Visible = False
Me.AddDeleteExp enseTypes.Visib le = False
Me.NavigationBu ttons = False
Me.Label48.Visi ble = False
Me.Line69.Visib le = False
Me.Label52.Visi ble = False
Me.Line72.Visib le = False
Me.manageu.Visi ble = False
End If

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

DoCmd.FindRecor d (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 1687
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********@hotm ail.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 OpenFilteredFor m()
DoCmd.OpenForm "frmMyFormName" , acNormal, ,
"[UserNameFieldFr omSourceTable]=" & CurrentUser
End Sub

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

If faq_IsUserInGro up("Admins", CurrentUser) Then
Me.RecordSource = "SELECT * FROM Employees"
else
Me.RecordSource = "SELECT * FROM Employees WHERE
Employees.Usern ame=" & 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.Userna me=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
1867
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 number like the cc number or check number, and the amount of the payment. I have a button on this form that when clicked adds the payment to a table via a sql statement in vba which works fine.
1
1826
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, check number or cc number, and then payment amount. Next I click a button to process the payment which uses a sql statement to insert the record into a payment table. This all works fine. My problem is that when I click the custom close
15
4671
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 field to start. If I edit that field and then click on the new record button in the navigation buttons, the form goes to a new record and each field has the default value of the previous record. If I put the focus in any field to start, edit that...
1
1889
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 B, I want it to open a find record dialog box before it opens the form so that you can locate the main color you are going to enter the variations for. The form should then open with the information from Table A already preloaded (or a dialog box...
3
6225
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 from the macro on the form I want to find the record in it just sits there and does not run. Could someone tell me how to fix this? Please be specific as I am new to Access.
6
2885
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 and the coresponding 'Id' from the lookup table is to be inserted into the field of the new record. I have two simple tables. "tblPerson" is the data table. The lookup
0
1267
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 departments opens up second form called frmEmployees. This form displays all the employees for the department selected in frmDepartment. This form has an unbound list box which retreives all the values from a query and displays all the names of...
10
4591
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 4. If no match can be found, adds a new record in Table 2 and enters the ComputerID automatcially. The goal is to create a new record in Table 2 when a new record is created in table 1 and have the ComputerID fields match with a 1-to-1...
22
11023
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 edits the telephone number. 2. UserB opens the same form and tries to navigate to customerA's record. At this point I want to inform UserB that the record is locked. How do
0
9892
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10997
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10718
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10347
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7889
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7067
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5731
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5917
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4134
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.