Macros

R

Randi

I am trying to write a macro that will search a form for a particular logon.
It will change depending on who is trying to signon. I am having a hard time
programming the macro to use the find button & allow the user to input their
id.

Any suggestions???
 
A

Arvin Meyer

You can't really search a form. A form displays and manipulates data on the
screen. Searching is done in the underlying data. Macros are generally not
as sufficient as VBA code for doing tasks like this. I suspect you want to
display data depending upon who's logging in. To do that you should use
user-level security:

http://support.microsoft.com/support/access/content/secfaq.asp

or at the very least get the Windows username:

http://www.mvps.org/access/api/api0008.htm

Perhaps you could explain specifically what you are trying to.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
J

John Vinson

I am trying to write a macro that will search a form for a particular logon.
It will change depending on who is trying to signon. I am having a hard time
programming the macro to use the find button & allow the user to input their
id.

Any suggestions???

A Macro is probably not the best tool for this purpose. A Query would
be pretty simple to implement; if you have a Form with an unbound
textbox, the user could type their ID into the textbox, and a Query
could use a criterion

=[Forms]![NameOfTheForm]![NameOfTheTextbox]

as a criterion to search a table (not a form: data is not stored in
forms, it's stored in tables) for the ID.

If you could explain where the ID is stored in your tables, and what
you want to do with it when you find it, we should be able to help in
more detail.

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
R

Randi

The ID is stored in a table called Main Table. It has two columns, employee
name and login id. There are then 4 additional tables that record the time &
date when the employee punches in for the day, out for lunch, in from lunch &
out for the day. The form that they clock in has 4 buttons for punching in.
I initially wanted only the 4 buttons on the main form, but I had to put the
id # because otherwise I was not able to tell who was clocking in or out.

I hope I'm not rambling and this makes sense.

Thanks for your help.

John Vinson said:
I am trying to write a macro that will search a form for a particular logon.
It will change depending on who is trying to signon. I am having a hard time
programming the macro to use the find button & allow the user to input their
id.

Any suggestions???

A Macro is probably not the best tool for this purpose. A Query would
be pretty simple to implement; if you have a Form with an unbound
textbox, the user could type their ID into the textbox, and a Query
could use a criterion

=[Forms]![NameOfTheForm]![NameOfTheTextbox]

as a criterion to search a table (not a form: data is not stored in
forms, it's stored in tables) for the ID.

If you could explain where the ID is stored in your tables, and what
you want to do with it when you find it, we should be able to help in
more detail.

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
J

John Vinson

The ID is stored in a table called Main Table. It has two columns, employee
name and login id. There are then 4 additional tables that record the time &
date when the employee punches in for the day, out for lunch, in from lunch &
out for the day. The form that they clock in has 4 buttons for punching in.
I initially wanted only the 4 buttons on the main form, but I had to put the
id # because otherwise I was not able to tell who was clocking in or out.

I hope I'm not rambling and this makes sense.


Hmmm... do you have *separate tables* for the four timeclock events?
That would not be the best design, in my opinion!

I'd suggest two tables:

Employees
EmployeeID
LastName
FirstName
<other bio data, department assignment, job title, etc>

Note that it's best to store names as two (or three, for middle names)
fields rather than one, and to store some additional information in
case two employees happen to have the same name. I once worked with
Dr. Lawrence David Wise and his colleague, Dr. Lawrence David Wise.

TimePunch
EmployeeID
PunchEvent Text
PunchTime Date/Time

PunchEvents
PunchEvent Text <e.g. "Start Of Day", "Out To Lunch", "In From
Lunch", "Out For Day", "Went Home Sick", <etc>

Have a Form based on Employees; put a Combo Box on the form using the
Combo Wizard "Find a Record" option to navigate to a particular
employee's record. Use a Subform based on TimePunch. With the
EmployeeID as the Master/Child Link Field, and a Default property of
Now() on PunchTime, all the user need do is select their name from the
combo, select the event from the subform combo, and exit the form.


John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
Top