Choosing between Tables from a form

R

Rudi

Hi

How do I create a form so that it displays a dropdown menu for certain
tables that I have created. For exmaple, say I want to add data in table 1, I
want to choose table 1 from a dropdown list in a form that I have created.

Thanks
 
N

Nikos Yannacopoulos

Rudi,

SELECT Name FROM MSysObjects WHERE Type = 1 AND Name Not Like "MSys*"

In the rowsource property of a combo (or a listbox) will populate it
with the names of the (non-system) tables. You could apply additional
filtering, like e.g.

SELECT Name FROM MSysObjects WHERE Type = 1 AND Name Like "*XYZ*"

If you only want to select tables whose name contains string XYZ, etc.

That said, from an application design standpoint, it is not good
practice to have users work directly in tables. The standard way for
working with data in tables is through forms.

HTH,
Nikos
 
R

Rudi

Yes, one possible strategy was to create a few tables (a table for each
employee) with the same structure (projects worked on, hours, etc) but I am
sure there is an easier way.

What I would like to do is to create come sort of login for employees. When
a certain employee has logged in, he must choose a date and project and hours
worked on the project. What would be the best way to implement this and how
can I create such a login interface? Afterwards I must be able to query any
employee on any date to see for how long he did what. Would I firstly create
an employee table and then a table with a date and projects and hours work
and then create a relationship between them?

Thanks!
 
L

Lynn Trapp

Yes, one possible strategy was to create a few tables (a table for each
employee) with the same structure (projects worked on, hours, etc) but I
am
sure there is an easier way.

there is definitely an easier way and a way that will keep you from pulling
your hair out later.
What I would like to do is to create come sort of login for employees.
When
a certain employee has logged in, he must choose a date and project and
hours
worked on the project. What would be the best way to implement this and
how
can I create such a login interface? Afterwards I must be able to query
any
employee on any date to see for how long he did what. Would I firstly
create
an employee table and then a table with a date and projects and hours work
and then create a relationship between them?

The best way to do that is to implement user level security, but that's not
a task for the faint of heart. There is a link to the Security FAQ on the
security page of my website. This document tells how to implement it. You
can then use the CurrentUser function to track an employee's projects.

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Big List: www.ltcomputerdesigns.com/JCReferences.html
 
R

Rudi

Okay, I have created a user level security and it works great. How would I
now go about it to enter and keep track of data for each employee using the
CurrentUser function? Would I create a table consisting of the date, project
worked on and the hours and implement it with each current user? I am still a
bit confused how I should go about it. Should I first creat a form...or what
should I do? Would there at the end be one table containing all the data for
each employee that have logged on? Thanks for your help so far!
 
R

Rudi

Hi

The name of my Form is "Timesheet1" and the object is "Names". Below is what
I understood I should do. I've implemented it and it works for the first user
(It displays the correct user on the form and enters it into the table), but
when the second user Logs in, it keeps the name of the first user. Below is
what I inserted into VB (Form_Timesheet1). Is this what you meant I should do?

Thanks!

Private Sub Form_BeforeUpdate(Cancel As Integer)
Form_Timesheet1.Names = CurrentUser()
End Sub
 
Top