Update combo box choice

SueBK

Registered User.
Local time
Today, 09:33
Joined
Apr 2, 2009
Messages
197
After a week on holidays I now face the monster again :eek:.

I have a form (let's called it "FORM1"). On the form is a combobox (COMBO1). Combo1 picks up a list from "tblProjectMaster".
SELECT tblProjectMaster.ProjectID, tblProjectMaster.[Project #], tblProjectMaster.[Project Title] FROM tblProjectMaster ORDER BY tblProjectMaster.[Project #];
So - it shows me the Project # and Project Title, but actually reads the ProjectID (which is the primary key).

I want to choose a project from the combo box, and then click the button (Click1) next to it to open another form (Form2) that shows me the project details. I have chosen to do it this way because on a bad day I know you can pick the wrong item on a drop box way too many times; and it gets very old and very frustrating, very quickly.

Issues:
When I click on the project I want on the combo box it doesn't choose it. The list stays dropped down, and project isn't even highlighted. I assume I need code for "on click" - but unsure what exactly.

Secondly, how do I bind the button to the choice in the combo box?

Thanks for your help!
 
Figured out the first one. Need to "allow edits" on the form. I can now chose a project; but now I still need to link it to the button to open the 2nd form.
 
Figured out the first one. Need to "allow edits" on the form. I can now chose a project; but now I still need to link it to the button to open the 2nd form.

Code:
DoCmd.OpenForm "YourFormNameHere", acNormal, , "[ProjectID]=" & Me.Combo1

If it is returning the combo ID as a number.
 
I tried that for days while working on it last and just could not get it to fire. Maybe I was doing something stoopid.

While I was away, someone else dumped some code on the button; and once I worked out the "allow edits" it worked! I copied/edited it for similar buttons I have on other forms.

Code used was:
On Error GoTo Err_Command47_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmProjectMaster"

stLinkCriteria = "[ProjectID]=" & Me![StartCombo01]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command47_Click:
Exit Sub
Err_Command47_Click:
MsgBox Err.Description
Resume Exit_Command47_Click
 
Well, the reason I can see is that you have a different combo name than Combo1 which is what you gave in your initial post. Your working code uses:
Me![StartCombo01]

So, StartCombo01 is not the same as Combo1 and it would have a problem if you don't pass it the right control names.
 

Users who are viewing this thread

Back
Top Bottom