Code for transferring query results to form?

S

Suzann

I have a database I've secured with user level security. I have a form based
on a query that will be used to add data to 3 tables (I'm using subforms for
each separate table). The query restricts access to the CurrentUser() and
will be run with owner's permission. I used the Northwind database as the
basis for this form and have followed other suggestions from previous posts.

The parts of the form are as follows:

Header - which includes UserName and WeekEndDate
Time Subform - UserName, WeekEndDate, Date, Project, StartTime, EndTime
Expenses Subform - UserName, WeekEndDate, Date, Expense, Amount
Mileage Subform - UserName, WeekEndDate, Date, Destination, Mileage

The source for the form is the above mentioned query. I have the UserName
and WeekEndDate properties set to not visible on the subforms and the
subforms are set as datasheets. Again, I've restricted access so the users
will only be able to view, edit and add records pertaining to themselves.
This group will not have access to underlying queries or tables and can only
run queries with owner's permission.

The information provided will allow me to accrue for unbilled project costs
at month-end closeout.

What I'd like to do is have a form header that automatically provides the
User's Name, Project, etc. This info would come from a query I made on the
User's table. Using the CurrentUser() feature, the query returns the info
that I need.

What code would I need to transfer the results from this query to the form
header? And what event would I attach the code to?

If I gave too much or too little info - please advise. I'm slowly getting
better acquainted with VBA and all the advice from people in other posts has
helped me enormously. Many thanks.

Suzann
 
A

Albert D.Kallal

If there is a bunch of fields to display from the data, then just use a
sub-form based on that query.....
 
S

Suzann

Thank you so much. I had tried that earlier, but didn't have all the
parent/child relationships defined the right way. I started over and it
worked great. Again, thanks.

Suzann
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top