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

Cannot select item in combobox

Status
Not open for further replies.

fdcusa

Technical User
Jul 27, 2006
40
US
Have a subform:
Name: frmProjectSub1
Default View: Continuous Forms

A combo box within the subform:
Name: cboProjectName
Control Source: Nothing
Row Source Type: Table/Query
Row Source: SELECT ProjectName FROM tblProjects WHERE tblProjects.Status LIKE "*" ORDER BY ProjectName;
Column Count: 1
Bound Column: 1
Visible: Yes
Enabled: Yes
Locked: No
Allow AutoCorrect: Yes
Tab Stop: Yes

OnClick Event:
Private Sub cboProjectName_Click()
With Me.frmProjectSub1.Form
Me.RecordsetClone.FindFirst "[ProjectName] = " & Me.cboProjectName
If Me.RecordsetClone.NoMatch Then
MsgBox "Can't find task " & Me.cboProjectName
Else
Me.Bookmark = Me.RecordsetClone.Bookmark
End If
End With
End Sub


Within the continous form, if I name the Control Source as ProjectName, and traverse through the records, the value in the combo box changes to the current selected row.

Problem: In the combo box, I do get the dropdown list of projects, when I click on a project - Nothing Happens! The listbox stays open on the item that I clicked on -- does not close-up and put the selected item in the combobox window. I'm stumped...
 
Why do you have CLICK event code? I don't see any need for it.

Does your combo box display the 'current' project name for a record, and allow you to update or change it?

I can't quite get the referential properties here, but it looks like you have a -MANY side relationship, with Project being one of the fields. The values for PROJECT are drawn from the lookup table of available project names...so far so good. The control source for your combo box should, I believe, be set to the field name in your -MANY side record that corresponds to the project name. This way, when the record has the focus, the value in the box will be the current project name, but the drop-down will contain ALL of the project names, so you can update it if necessary.

Actually, the easiest way to do this is to simply set the -MANY side project name field to be a combo box, with the appropriate row source, in your table design of the -MANY side table. This creates an automatic referential link to the lookup table, and saves having to code it in each and every form.





--------------------------------------
"For a successful technology, reality must take precedence over public relations, for Nature cannot be fooled." - Richard P. Feynman
 
The subform (a continous form) lists all of the projects in the table, one per line.

In the ComboBox, which is in the subform, the purpose of the OnClick event is to move the row pointer to the selected project within the subform - like acLast/acNext, but pointing to the specific row. Making ProjectName (the field) the Control Source doesn't correct the issue.

Giving some thought, it now seems the ComboBox isn't even necessary, as the user can already scroll through the project list summaries.

But, the nagging question still exists... Clicking on the combobox opens the list. I can scroll the list and click on a ProjectName, but nothing happens! Why doesn't the Click trigger the OnClick event? In a similar form, it will work -- the difference is its Row Source is the actual table and everything is on one form, rather than a SQL statement like I have here which is imbedded in a subform.

Is the problem with the RowSource, or that the ComboBox is within the subform? Or?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top