ComboBox won't display what is selected...

M

maura

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
 
K

Ken Snell \(MVP\)

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?
 
M

maura

ColumnCount = 3
ColumnWide = 0";1";1"
BoundColumn = 1
RowSource = SELECT qryRentalAgreement.RentalAgreementId,
qryRentalAgreement.RenterLastName, qryRentalAgreement.RenterFirstName FROM
qryRentalAgreement ORDER BY qryRentalAgreement.RenterLastName,
qryRentalAgreement.RenterFirstName;

Ken Snell (MVP) said:
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?

--

Ken Snell
<MS ACCESS MVP>




maura said:
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
 
K

Ken Snell \(MVP\)

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


--

Ken Snell
<MS ACCESS MVP>


maura said:
ColumnCount = 3
ColumnWide = 0";1";1"
BoundColumn = 1
RowSource = SELECT qryRentalAgreement.RentalAgreementId,
qryRentalAgreement.RenterLastName, qryRentalAgreement.RenterFirstName FROM
qryRentalAgreement ORDER BY qryRentalAgreement.RenterLastName,
qryRentalAgreement.RenterFirstName;

Ken Snell (MVP) said:
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?

--

Ken Snell
<MS ACCESS MVP>




maura said:
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
 
M

maura

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



Ken Snell (MVP) said:
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


--

Ken Snell
<MS ACCESS MVP>


maura said:
ColumnCount = 3
ColumnWide = 0";1";1"
BoundColumn = 1
RowSource = SELECT qryRentalAgreement.RentalAgreementId,
qryRentalAgreement.RenterLastName, qryRentalAgreement.RenterFirstName FROM
qryRentalAgreement ORDER BY qryRentalAgreement.RenterLastName,
qryRentalAgreement.RenterFirstName;

Ken Snell (MVP) said:
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?

--

Ken Snell
<MS ACCESS MVP>




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
 
K

Ken Snell \(MVP\)

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 ....
--

Ken Snell
<MS ACCESS MVP>





maura said:
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



Ken Snell (MVP) said:
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


--

Ken Snell
<MS ACCESS MVP>


maura said:
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?
What is the BoundColumn property's value for the combo box?
What is the RowSource property's value for the combo box?

--

Ken Snell
<MS ACCESS MVP>




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
 

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