Control on form not always displaying data

D

Darhl Thomason

I have a combo box control (cboDistrict) on my form that does not always
show the data stored in the current record, and sometimes it does. I can't
figure out why it sometimes shows and sometimes doesn't. If I open the
combo box, the correct value is highlighted in the list, and the correct
value is entered in that record's field in the db table.

cboDistrict is set to populate based on the value of another combo box
(cboRegion), the code behind cboDistrict is:

Private Sub cboDistrict_GotFocus()
strSQL2 = "SELECT DistrictID, DistrictName " _
& " FROM tblDistrict WHERE RegionID = " & Me.cboRegion _
& " ORDER BY DistrictName"
Me.cboDistrict.RowSource = strSQL2
End Sub

I'm thinking that it may be because the combo box is set to update when it
gets focus, but it seems like that shouldn't matter if there is a value
stored in that record. The combo box population is really only if you want
to change it.

Any ideas/help would be appreciated.

Thanks,

Darhl
 
A

Arvin Meyer [MVP]

In a continuous form, the code which displays the record in the second combo
box often won't be the same for a different record. If you have multiple
records in that continuous form, you often see that behavior because the
parameters of the first record don't match subsequent ones. The cure is to
use single form view whenever you have dependant combo boxes.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
 
D

Darhl Thomason

Arvin,

My form is already in single form view...what should I check next?

Thanks,

Darhl
 

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