Combo problem

Markvand

Registered User.
Local time
Today, 09:39
Joined
Jul 13, 2004
Messages
88
hi,

I am working on Project Database,

The thing I want to achieve is to have a combo with a employees name for expample and be able to pick one and automaticaly store it in table, clear the combo and do the same with another employee.

I'm getting something close with this code:

Private Sub Employee_Click()

Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("tblProjectEmployee")

rs.AddNew
rs![EmployeeDep] = Me.[Employee]
rs.Update
rs.Close

End Sub

I've got a strange feeling that I should use some sort of counter here, but no idea how.

The purpose behind this is to store few names under one project ID. Maybe there is another way to do this.

Any help would be great.

Cheers
 
tblProjects
ProjectID
ProjectName
other details...

tblEmployees
EmployeeID
Forename
Surname
other details ....

tblProjectsToEmployees
ProjectID
EmployeeID

With that structure, you can just use a form/subform combination rather than a combobox and VBA.
 
That's clear, but is it possible with combo and VBA, it's just that I always like to chalange with something and I reckon this looks better with combo. I might be subjective. :rolleyes:
 
Markvand said:
it's just that I always like to chalange with something and I reckon this looks better with combo. I might be subjective. :rolleyes:

Why challenge yourself with an inefficient method when Microsoft Access can click it all together for you without any interference? :confused:

I enjoy challenges but I enjoy them where they're warranted. :)
 
Fair enough, thnx anyway,
just for curiousity is there a way? or you just don't know

Rich how did u guess? :p

Regards
 
Markvand, There is a way, it just seems irrational.

1. Do your tables like you were going to do the subform method.
2. On your original main form put the combo box.
3. Set combo box row source to the employee tables 'EmployeeName" field and have it sorted ascending.
4. On the after update event on the combo box, do code that appends the current project id and employeeName in the combox to the projectEmployee table.

Of course if you tried to append a duplicate, you would have to have the pk in the projectEmployee table set to the projectID and employeeName as a composite pk.

There are some more work arounds, but they are clunky, like this one...

ken
 

Users who are viewing this thread

Back
Top Bottom