Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / August 2006

Tip: Looking for answers? Try searching our database.

Combo Box search

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Matt Dawson - 31 Aug 2006 09:44 GMT
I have set up a form to search for a record in a combo box under field
Request ID. When the field is unbound i can carry out the search and find the
record but when i scroll through the records this Request ID remains even as
I am scrolling through. When the requestID is bound, it produces an error
message about duplicating the data!
Any help would be much appreciated
Matt
Klatuu - 31 Aug 2006 13:55 GMT
You are describing normal behaviour for a combo.  
It is possible to make a bound combo work correctly, but it is much easier
to leave it unbound.  It doesn't really matter that it does not stay in sync
with the current record because it is not bound and has no relation to it.  
It is really only for searching; however, I do understand that some users can
be confused by this.  There a a number of ways to handle it.

One way I have seen is to put the combo in the header section of the form
and make the default of the header not visible.  Then have a Search command
button that exposes the combo and hide the header in the After Update and Not
in List events when the search is complete.

If you want the combo to stay in sync with the form's current record, you
can put this in the Current event of the form:

If Me.NewRecord Then
   Me.cboMyCombo = Null
Else
   Me.cboMyCombo = Me.txtFieldToMatch
End If

> I have set up a form to search for a record in a combo box under field
> Request ID. When the field is unbound i can carry out the search and find the
[quoted text clipped - 3 lines]
> Any help would be much appreciated
> Matt
Matt Dawson - 31 Aug 2006 14:46 GMT
Klatuu,

Yes i understand that this is the usual behavoir but as the system is not
going to be used by me i need this to be as user friendly as possible without
any potential mistakes!

My current code reads:

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

   Set rs = Me.Recordset.Clone
   rs.FindFirst "[Request ID] = '" & Me![Combo24] & "'"
   If Not rs.EOF Then
End Sub

Private Sub Form_Current()
If Me.NewRecord Then
   Me.cbo [Combo24] = Null
Else
Me.cbo [Combo24] = Me.txtFieldToMatch
End If
End Sub

Where are my errors?

Matt

> You are describing normal behaviour for a combo.  
> It is possible to make a bound combo work correctly, but it is much easier
[quoted text clipped - 24 lines]
> > Any help would be much appreciated
> > Matt
Klatuu - 31 Aug 2006 16:50 GMT
Use the NoMatch property instead of EOF

   Set rs = Me.Recordset.Clone
   rs.FindFirst "[Request ID] = '" & Me![Combo24] & "'"
   If Not rs.NoMatch Then

txtFieldToMatch is only an example, you need to be using the name of the
text box that is bound to the field that the combo searches on.

   Me.cbo [Combo24] = Me.txtFieldToMatch

> Klatuu,
>
[quoted text clipped - 53 lines]
> > > Any help would be much appreciated
> > > Matt
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.