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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to fill atext or combo box automatically

Status
Not open for further replies.

luismagally

IS-IT--Management
Jan 12, 2005
21
PR
I've got a timesheet table which records projects, hours and dates from employees working in any given project. When I select the project name, I want all related fields (customer name and project id) to fill automatically. This are my tables:

timesheet projects clients
id |------project_id client_id
projectid--||-----project |-------client
project-----| |---client-----| client_town
client---------|
discipline
date.......(til the end)


It's one client, many projects, exclusive project id which fill the timesheet table and project table. If I put the timesheet table into a form alone, with nothing but the table, how do I fill the project id and the client fields by only choosing the project name?

I think i must be doing something really wrong here...

Thanks
 
If your ProjectID, Project and Client are stored in the table Projects, why would you want to also store Project and Client in the table 'Timesheet'? It makes sense to only store the ProjectID. What if the client's name changes? You'd have to go thru all Timesheet records and fix them. It just doesn't make sense to store the same data in two places.

So I suggest you take Project and Client out of the Timesheet table. Later, in queries and reports, you can display them by joining to the table Projects.

So say on your current form, you have a combo box where the user picks a project. The Control Source would be "ProjectID" (Which is the field the result of the combo box pick will reside), and the RowSource of the combo box would be the table Projects.

Columns = 3
Column Widths = 0,1.5,0 {hides first and third columns}
Bound Column = 1 {Makes ProjectID go into the table}

Then say you make text boxes "Project" and "Client" be UNBOUND, meaning they have no control source. In the text box "Projects", put

=cboProjectID.column(0)

and in the control source of Client text box put:

=cboProjectID.column(2)

this is assuming your combo box is called cboProjectID.

This way, when the user chooses a project, the associated info is displayed for their reference. But it's not saved (again) in the TimeSheets table.

Hope this helps!

g

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
or luismagally, you can create a subform linked by primary & foreign keys...

or create recordset based on Project ID, Loop & add records to desired form or table....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top