Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Query from access form.

Status
Not open for further replies.

Daenks

Programmer
Dec 19, 2004
3
US
Hi, I'm trying to create a databse for my company where you can access hours spent on jobs by employee.

I have the following tables set up: "employees", "jobs" and "hours".

The Last Field in [Employees] is a relationship with Hours

On the form for employees i want to list every record in HOURS that has the same name as the employee being looked at.

SO:
SELECT Hours.Employee, Hours.Job, Hours.Hours FROM Hours WHERE Hours.Employee=Nickname

Now.. this WORKS. except that when i change records it does not update the contents of the ListBox!

So i load the form, and the values listed are correct for the 1st employee that is there, but when i goto the next record, it still lists the values for thee 1st employee.

I tried to use the Form.OnCurrent event to change the listbox.RowSource value before loading the record, but I'm told that i cannot edit the properites of a control unless it has focus (not true in real VB, why here?).

anyway, any solution you have would be greatly appreciated.

thanks in advance,
Dan

 
I thought i should specify....
in the
WHERE Hours.Employee=Nickname
clause
Nickname is the name of a Textbox on the form that contains the nickname(used in hours.employee) of the employee.

 
In the Current event procedure of the Employee form:
Me![name of hours listbox].RowSource = "SELECT Hours.Employee, Hours.Job, Hours.Hours FROM Hours WHERE Hours.Employee='" & Me!Nickname "'"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top