Combo Box on Form

M

MDI Anne

I have placed a combo box on a form. When I scroll down with the roller on
my mouse - it works. When I click on the record selector on the bottom of
the form - it works. When I click on the drop down box to make my selection
- it doesn't work. The selection changes, but the rest of the form stays the
same.

Suggestions?

Thanx!
 
J

Jeanette Cunningham

Hi Anne,
put code in the after update event of the combo box like this

cboSubcategory is the name of the combo
SubcategoryID is the name of the field in the 1st (hidden) field of the
combo

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

Set rs = Me.Recordset.Clone
rs.FindFirst "[SubcategoryID] = " & (Nz(Me![cboSubcategory], 0)
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark
End if

End Sub

Jeanette Cunningham
 
K

Klatuu

I think you have spazed your data.

If the combo box is a bound control, each time you make a selection, you are
changing the value in underlying table.

Combo's used for searching should be unbound and only used for searching.
Then to make the selected record the current record, you use the After Update
event of the combo box:

If Not IsNull(Me.MyCombo) Then
With Me.RecordsetClone
.FindFirst "[MyField] = " & Me.MyCombo
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With
End If
 
K

Klatuu

Jeanette,
FYI, you should always close recordsets before exiting the procedure and set
the reference to Nothing
rs.Close
Set rs = Nothing

Most of the time, it will not be a problem, but it is good housekeeping.

And, read my response. Note I use the recordsetclone which means I don't
have to take the time and resource to create a recordset and close it.


--
Dave Hargis, Microsoft Access MVP


Jeanette Cunningham said:
Hi Anne,
put code in the after update event of the combo box like this

cboSubcategory is the name of the combo
SubcategoryID is the name of the field in the 1st (hidden) field of the
combo

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

Set rs = Me.Recordset.Clone
rs.FindFirst "[SubcategoryID] = " & (Nz(Me![cboSubcategory], 0)
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark
End if

End Sub

Jeanette Cunningham



MDI Anne said:
I have placed a combo box on a form. When I scroll down with the roller on
my mouse - it works. When I click on the record selector on the bottom of
the form - it works. When I click on the drop down box to make my
selection
- it doesn't work. The selection changes, but the rest of the form stays
the
same.

Suggestions?

Thanx!
 

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