Combo box display first item in list

C

CharlesD

Hi,

I have a form that contains two combo boxes. One is cboMedicare for Medicare
codes and the other cboLocation that contains valid locations for the
Medicare code chosen in the combo box cboMedicare, I set the variable
..txtMedicareCode = .cboMedicare.Column(1). The cboLocation is populated
using the following SQL statement:

SELECT tblLocation.apkLOCATION, tblLocation.DESCRIPTION,
tblMedicare_Business_Rules_All_Fields.SERV_CODE
FROM tblLocation INNER JOIN tblMedicare_Business_Rules_All_Fields ON
tblLocation.apkLOCATION = tblMedicare_Business_Rules_All_Fields.apkLOCATION
WHERE
(((tblMedicare_Business_Rules_All_Fields.SERV_CODE)=[Forms]![frmDailyBillings]![txtMedicareCode]))
ORDER BY tblLocation.apkLOCATION;

Everything works well, but I cannot seem to get the combo box for
cboLocation to show the first record in the query results. When you use the
down arrow on the cboLocation the combo box has the proper locations for the
medicare code, I am able to have a text field show the
tblLocation.DESCRIPTION from the SQL query, by using the code:
With Me
.mservice = .cboMedicare.Column(2)
.txtMedicareCode = .cboMedicare.Column(1)
.txtMedicareCode.Requery
.cboLocation.Requery
' .cboLocation = .cbolocation.ItemData(0)
' .cboLocation = .cboLocation.Column(0)
.cboLocation = .cboLocation.Column(0, 0)
.txtLocationDesc = .cboLocation.Column(1, 0)
End With
I am not able to get the cboLocation to show the first row in the records
populating the combo box. As you can see, I have tried a number of
suggestions I have read on this site, but to no avail. Would someone have an
answer to this issue. It would be greatly appreciated. I have tried for
several nights to get this working.

Regards,

CharlesD
 
M

Marshall Barton

CharlesD said:
I have a form that contains two combo boxes. One is cboMedicare for Medicare
codes and the other cboLocation that contains valid locations for the
Medicare code chosen in the combo box cboMedicare, I set the variable
.txtMedicareCode = .cboMedicare.Column(1). The cboLocation is populated
using the following SQL statement:

SELECT tblLocation.apkLOCATION, tblLocation.DESCRIPTION,
tblMedicare_Business_Rules_All_Fields.SERV_CODE
FROM tblLocation INNER JOIN tblMedicare_Business_Rules_All_Fields ON
tblLocation.apkLOCATION = tblMedicare_Business_Rules_All_Fields.apkLOCATION
WHERE
(((tblMedicare_Business_Rules_All_Fields.SERV_CODE)=[Forms]![frmDailyBillings]![txtMedicareCode]))
ORDER BY tblLocation.apkLOCATION;

Everything works well, but I cannot seem to get the combo box for
cboLocation to show the first record in the query results. When you use the
down arrow on the cboLocation the combo box has the proper locations for the
medicare code, I am able to have a text field show the
tblLocation.DESCRIPTION from the SQL query, by using the code:
With Me
.mservice = .cboMedicare.Column(2)
.txtMedicareCode = .cboMedicare.Column(1)
.txtMedicareCode.Requery
.cboLocation.Requery
' .cboLocation = .cbolocation.ItemData(0)
' .cboLocation = .cboLocation.Column(0)
.cboLocation = .cboLocation.Column(0, 0)
.txtLocationDesc = .cboLocation.Column(1, 0)
End With
I am not able to get the cboLocation to show the first row in the records
populating the combo box. As you can see, I have tried a number of
suggestions I have read on this site, but to no avail. Would someone have an
answer to this issue. It would be greatly appreciated. I have tried for
several nights to get this working.


Check the combo box's ColumnHeads property.

If that was the problem, I think(?) your code can be reduced
to:

With Me
.mservice = .cboMedicare.Column(2)
.txtMedicareCode = .cboMedicare.Column(1)
.cboLocation.Requery
.cboLocation = .cbolocation.ItemData(0)
.txtLocationDesc = .cboLocation.Column(1)
End With

I can't tell for sure from what you posted, but you might
not have the BoundColumn property set to corrrespond to the
location identifyer field.
 
C

CharlesD

Hi Marsh,

Thanks for replying. The combo box is bound to column 0 and no headings.
When I go to the Immediate window:
? Me.cboLocation.Column(0, 0) has the correct value and
Me..cboLocation.Column(1, 0) is correct.
? Me..cboLocation.itemdata(0) has null and the combo box is not populated
when set to this value?

Regards,

CharlesD

Marshall Barton said:
CharlesD said:
I have a form that contains two combo boxes. One is cboMedicare for Medicare
codes and the other cboLocation that contains valid locations for the
Medicare code chosen in the combo box cboMedicare, I set the variable
.txtMedicareCode = .cboMedicare.Column(1). The cboLocation is populated
using the following SQL statement:

SELECT tblLocation.apkLOCATION, tblLocation.DESCRIPTION,
tblMedicare_Business_Rules_All_Fields.SERV_CODE
FROM tblLocation INNER JOIN tblMedicare_Business_Rules_All_Fields ON
tblLocation.apkLOCATION = tblMedicare_Business_Rules_All_Fields.apkLOCATION
WHERE
(((tblMedicare_Business_Rules_All_Fields.SERV_CODE)=[Forms]![frmDailyBillings]![txtMedicareCode]))
ORDER BY tblLocation.apkLOCATION;

Everything works well, but I cannot seem to get the combo box for
cboLocation to show the first record in the query results. When you use the
down arrow on the cboLocation the combo box has the proper locations for the
medicare code, I am able to have a text field show the
tblLocation.DESCRIPTION from the SQL query, by using the code:
With Me
.mservice = .cboMedicare.Column(2)
.txtMedicareCode = .cboMedicare.Column(1)
.txtMedicareCode.Requery
.cboLocation.Requery
' .cboLocation = .cbolocation.ItemData(0)
' .cboLocation = .cboLocation.Column(0)
.cboLocation = .cboLocation.Column(0, 0)
.txtLocationDesc = .cboLocation.Column(1, 0)
End With
I am not able to get the cboLocation to show the first row in the records
populating the combo box. As you can see, I have tried a number of
suggestions I have read on this site, but to no avail. Would someone have an
answer to this issue. It would be greatly appreciated. I have tried for
several nights to get this working.


Check the combo box's ColumnHeads property.

If that was the problem, I think(?) your code can be reduced
to:

With Me
.mservice = .cboMedicare.Column(2)
.txtMedicareCode = .cboMedicare.Column(1)
.cboLocation.Requery
.cboLocation = .cbolocation.ItemData(0)
.txtLocationDesc = .cboLocation.Column(1)
End With

I can't tell for sure from what you posted, but you might
not have the BoundColumn property set to corrrespond to the
location identifyer field.
 
M

Marshall Barton

CharlesD said:
The combo box is bound to column 0 and no headings.
When I go to the Immediate window:
? Me.cboLocation.Column(0, 0) has the correct value and
Me..cboLocation.Column(1, 0) is correct.
? Me..cboLocation.itemdata(0) has null and the combo box is not populated
when set to this value?


That is the expected result when you set the BoundColumn
property to 0. Maybe you intended to use 1?

Ignoring the extra dot, I don't imderstand the significance
of you saying
"Me..cboLocation.Column(1,0) is correct"
The first column in the second row doesn't appear to have
anything to do with this discussion. My A2003 Help topic on
the Column property is wrong about the arguments so maybe
you meant to use
Me.cboLocation.Column(0,1)
 
C

CharlesD

Hi Marsh,

Thanks for your response. When I set the boundColumn to 1 all worked.

When I looked at the value in Me.cboLocation.Column(1,0) it had the correct
value. Thought I was looking at column 1 row 0.

Anyway, have changed to follow your code. Thanks, I was struggling with this.

Regards,

CharlesD
 

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