Combo Box not working right!

M

magmike

My Combo Box, if you select the arrow, WILL open and display data.
HOWEVER, when an item is clicked on, it does NOTHING and the drop down
menu does not disappear. Also, if one put the the cursor in the combo
box, it WILL blink, but one CANNOT type in it.

The combo box IS enabled. Can anyone think of any reason it would act
this way?

The code behind it:

Private Sub Combo29_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[ID] = " & Str(Nz(Me![Combo29], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
Me.password_entry.SetFocus
Me.Command41.Visible = False
End Sub

Thanks in advance!
magmike
 
J

Jeff Boyce

An alternate approach to creating a recordset and finding the "first" record
with "ID" would be as follows:

* add an unbound combobox to the header of a form based on a query
* base that combobox on a query that returns enough info for the user to
find the correct record
* in the form's query, use a reference to the combobox on the form for the
selection criterion (usually the ID field)
* in the combobox's AfterUpdate event, use Me.Requery

The next effect of this approach is that the form opens without any records
(the combobox is empty, so the query that feeds the form returns no
records). When a record is selected from the combobox, the form requeries
its source, the query "sees" the selected record in the combobox, and loads
that record in the form.

JOPO (just one person's opinion)

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
M

magmike

An alternate approach to creating a recordset and finding the "first" record
with "ID" would be as follows:

* add an unbound combobox to the header of a form based on a query
* base that combobox on a query that returns enough info for the user to
find the correct record
* in the form's query, use a reference to the combobox on the form for the
selection criterion (usually the ID field)
* in the combobox's AfterUpdate event, use Me.Requery

The next effect of this approach is that the form opens without any records
(the combobox is empty, so the query that feeds the form returns no
records).  When a record is selected from the combobox, the form requeries
its source, the query "sees" the selected record in the combobox, and loads
that record in the form.

JOPO (just one person's opinion)

Regards

Jeff Boyce
Microsoft Office/Access MVP




My Combo Box, if you select the arrow, WILL open and display data.
HOWEVER, when an item is clicked on, it does NOTHING and the drop down
menu does not disappear. Also, if one put the the cursor in the combo
box, it WILL blink, but one CANNOT type in it.
The combo box IS enabled. Can anyone think of any reason it would act
this way?
The code behind it:
Private Sub Combo29_AfterUpdate()
   ' Find the record that matches the control.
   Dim rs As Object
   Set rs = Me.Recordset.Clone
   rs.FindFirst "[ID] = " & Str(Nz(Me![Combo29], 0))
   If Not rs.EOF Then Me.Bookmark = rs.Bookmark
   Me.password_entry.SetFocus
   Me.Command41.Visible = False
End Sub
Thanks in advance!
magmike- Hide quoted text -

- Show quoted text -

I like it. Just one question - what do you mean by "In the form's
query, use a reference to the combobox on the form for the selection
criterion" - I'm confused by this statement (my fault i'm sure), how
would I do that?

Current Query:

SELECT DISTINCTROW ProspectTable.*
FROM ProspectTable
ORDER BY ProspectTable.Company;

Currently, the combo box is on the form - not in the header and it is
called Combo29

mike
 
J

Jeff Boyce

I typically base forms on underlying queries, not directly on the tables.

In a query that "feeds" Form1, to implement what I described, I'd have a
selection criterion for the recordID field that looks something like:

Forms!Form1!cboMySelectionCombobox

This is how the query that feeds the form knows which record to display in
the form ... the one selected in the (unbound) combobox!

Good luck!

Regards

Jeff Boyce
Microsoft Office/Access MVP


An alternate approach to creating a recordset and finding the "first"
record
with "ID" would be as follows:

* add an unbound combobox to the header of a form based on a query
* base that combobox on a query that returns enough info for the user to
find the correct record
* in the form's query, use a reference to the combobox on the form for the
selection criterion (usually the ID field)
* in the combobox's AfterUpdate event, use Me.Requery

The next effect of this approach is that the form opens without any
records
(the combobox is empty, so the query that feeds the form returns no
records). When a record is selected from the combobox, the form requeries
its source, the query "sees" the selected record in the combobox, and
loads
that record in the form.

JOPO (just one person's opinion)

Regards

Jeff Boyce
Microsoft Office/Access MVP




My Combo Box, if you select the arrow, WILL open and display data.
HOWEVER, when an item is clicked on, it does NOTHING and the drop down
menu does not disappear. Also, if one put the the cursor in the combo
box, it WILL blink, but one CANNOT type in it.
The combo box IS enabled. Can anyone think of any reason it would act
this way?
The code behind it:
Private Sub Combo29_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[ID] = " & Str(Nz(Me![Combo29], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
Me.password_entry.SetFocus
Me.Command41.Visible = False
End Sub
Thanks in advance!
magmike- Hide quoted text -

- Show quoted text -

I like it. Just one question - what do you mean by "In the form's
query, use a reference to the combobox on the form for the selection
criterion" - I'm confused by this statement (my fault i'm sure), how
would I do that?

Current Query:

SELECT DISTINCTROW ProspectTable.*
FROM ProspectTable
ORDER BY ProspectTable.Company;

Currently, the combo box is on the form - not in the header and it is
called Combo29

mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top