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 Programming / May 2007

Tip: Looking for answers? Try searching our database.

ComboBox won't display what is selected...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
maura - 19 May 2007 18:46 GMT
I have a combo box that is doing a search by renterlastname. Problem is that
there could be multiple times a renter's last name appears. The combo box is
based on
qryRentalAgreement and I have it references the RentalAgreementID. And it
works, EXCEPT... the name won't appear in the combo box once you have
selected it. So you type in Fitzgerald, and it will pull up the record, but
the name won't show. I can go back and type in Fitzgerald and select the 2nd
record down and it shows the other record, but again the name doesn't stay in
the box. Any ideas. I have another database (repossessions, and sometimes we
repossess a person multiple times) and I copied the code from that database,
it works fine for the repo db, but not for this one... Any thoughts?

Private Sub Form_Current()
   cboRentalAgreement.Value = RentalAgreementId
   cboRenterLast.Value = RenterLastName

End Sub

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

   Set rs = Me.Recordset.Clone
   rs.FindFirst "[RentalAgreementId] = " & Me![cboRenterLast].Value & ""
   If Not rs.EOF Then Me.Bookmark = rs.Bookmark
   
   'cboRenterLast.Text = Me![RenterLastName]
   
End Sub
Ken Snell (MVP) - 19 May 2007 18:54 GMT
What is the ColumnCount property's value for the combo box?
What is the ColumnWidths property's value for the combo box?
What is the BoundColumn property's value for the combo box?
What is the RowSource property's value for the combo box?

Signature

       Ken Snell
<MS ACCESS MVP>

>I have a combo box that is doing a search by renterlastname. Problem is
>that
[quoted text clipped - 32 lines]
>
> End Sub
maura - 19 May 2007 19:07 GMT
ColumnCount = 3
ColumnWide = 0";1";1"
BoundColumn = 1
RowSource = SELECT qryRentalAgreement.RentalAgreementId,
qryRentalAgreement.RenterLastName, qryRentalAgreement.RenterFirstName FROM
qryRentalAgreement ORDER BY qryRentalAgreement.RenterLastName,
qryRentalAgreement.RenterFirstName;

> What is the ColumnCount property's value for the combo box?
> What is the ColumnWidths property's value for the combo box?
[quoted text clipped - 37 lines]
> >
> > End Sub
Ken Snell (MVP) - 19 May 2007 21:02 GMT
What is the ControlSource property's value?

Your other properties look ok. Where is the combo box on the form?

I'd change your AfterUpdate event procedure code to use the RecordsetClone
instead of the Recordset.Clone:

Private Sub cboRenterLast_AfterUpdate()
   ' Find the record that matches the control.
   With Me.RecordsetClone
       .FindFirst "[RentalAgreementId] = " & Me![cboRenterLast].Value
       If .NoMatch = False Then Me.Bookmark = .Bookmark
   End With
End Sub

Signature

       Ken Snell
<MS ACCESS MVP>

> ColumnCount = 3
> ColumnWide = 0";1";1"
[quoted text clipped - 51 lines]
>> >
>> > End Sub
maura - 22 May 2007 20:54 GMT
Hey Ken a belated reply, but I wanted to let you know I redid the combo box
after your initial response (because I thought I had the bound column wrong).
And that combo box actually works... I put the RentalAgreementId as the 2nd
column and bound it to it. I did leave my other combo box and tried to
trouble shoot it, the code you gave me below didn't work. I really wanted to
figure out what I did wrong, and I may keep messing with it, but I did want
to THANK YOU for spurring my mind and getting me to go at this one more time
(I think I have a better understanding of the combo box).

I do not have a control source... is this a problem? THANKS again!!!!

Column Count = 2
ColumnWide = 2";1"
BoundColumn = 1
RowSource = SELECT [RenterLastName] & ", " & [RenterFirstName] AS Expr1,
qryRentalAgreement.RentalAgreementId FROM qryRentalAgreement ORDER BY
[RenterLastName] & ", " & [RenterFirstName],
qryRentalAgreement.RentalAgreementId;

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

   Set rs = Me.Recordset.Clone
   rs.FindFirst "[RentalAgreementId] = " & Me![cboLastName].Value & ""
   If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

> What is the ControlSource property's value?
>
[quoted text clipped - 66 lines]
> >> >
> >> > End Sub
Ken Snell (MVP) - 23 May 2007 00:53 GMT
Sometimes, rebuilding a control fixes many weird problems < grin >.

You do not want a control source value for a combo box that is being used to
select a value for filtering / searching, so your setup is correct.

When you say the code doesn't work, what does that mean -- gave wrong
results? gave no results? gave an error? gave ....
Signature


       Ken Snell
<MS ACCESS MVP>

> Hey Ken a belated reply, but I wanted to let you know I redid the combo
> box
[quoted text clipped - 110 lines]
>> >> >
>> >> > End Sub
 
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.