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

Problem looking up a records with a combo box? 3

Status
Not open for further replies.

grobermatic

Technical User
Dec 21, 2002
153
0
0
GB
Ok, I think that this should be pretty simple but I keep getting stuck!

I have a small form with a combo box at the top which holds a list of employee names. This is taken from a table which hold only these names (FLANames)

The idea is that the user will select an employees name and the continuous subform below will display a list of dates that the selected employee has worked. (from another table PerformanceInfo)

I was getting successful results until I changed the primary key to a combined primary key. This needs to remain.

I think the problem is that when I select the nane from the combo box, the form is trying to create a new record in the underlying table, an error is generated because the primary key is not being filled in for the new record.

I dont want to create a new record, I only want to lookup and select previousley entered records.

I tried changing the "DATA ENTRY" property to no but when I do this the form opens with records already displayed which I don't want.

I would be grateful for any help anyone could offer

Craig
 
Hi

I assume the combo box on the amin form is unbound?, if not, then you should make it so.

You then select the sub form and set the Master\Child link property to be the employeeId (child), and the Combobox (PArent), Acecss will do the rest to cause the Employee\Date rcords for the appropriate Employye to be displayed.

However a point, you imply in the quetion that the Employee NAME is the unique id of the Employee, this is somewhat risky, since the chance of having two Employees with the same name is fairly high.

The 'usual' thing to do is to have an EmployeeId, to uniquely identify each Employee (this may be an autonumber fields, and may if you wish be hidden from the user), if you adopt this approach (or if I have missunderstood and you are already doing this, then the above advice still holds good, you just make your combo box a two column combo box (id and Name), with the first column(Id) having zero width, so the user does not see it.

Yet another piece of advice, if you have not already done so, split Employee name into (at least) two columns in your Employee table, ie First Name and Second Name, it will save tears later when you need to sort by surname or some such, believe me it WILL happen!

Hope this helps Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Hi!

I HIGHLY recommend Ken's statement concerning the Names, I have cried those tears myself!!!

Excellent!

Rick.
 
Success!!!

Thanks again Ken for another accurate response!

Whilst playing about with alternative methods I have also setup the same kind of system but instead of a subform, the selection from the combo box populates a listbox by means of an SQL statement.

Both work great and so now my bosses have a choice, I'll leave it up to them

Thanks again

Craig [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top