A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Combo Box on Form



 
 
Thread Tools Display Modes
  #1  
Old January 9th, 2008, 10:36 PM posted to microsoft.public.access.forms
MDI Anne
external usenet poster
 
Posts: 32
Default Combo Box on Form

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!
  #2  
Old January 9th, 2008, 10:53 PM posted to microsoft.public.access.forms
Jeanette Cunningham
external usenet poster
 
Posts: 2,190
Default Combo Box on Form

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" wrote in message
...
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!



  #3  
Old January 9th, 2008, 10:56 PM posted to microsoft.public.access.forms
Klatuu
external usenet poster
 
Posts: 7,074
Default Combo Box on Form

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
--
Dave Hargis, Microsoft Access MVP


"MDI Anne" wrote:

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!

  #4  
Old January 9th, 2008, 11:03 PM posted to microsoft.public.access.forms
Klatuu
external usenet poster
 
Posts: 7,074
Default Combo Box on Form

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" wrote:

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" wrote in message
...
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!




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:49 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.