[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 651
  • Last Modified:

ItemData and ListIndex property when using a recordset

Hi there,
I'm getting a little confused about retrieveing data from a recordset and loading it to a Access form. I'm able to get data successfully, but when I load the data to a cbo box, I'm using the ListIndex and ItemData improperly.

This is what I have:
With Me
            .txtVendorNo = rstSearchResults!VendorNumber
            .cboDistrict.ItemData(.cboDistrict.ListIndex) = rstSearchResults!DistrictID
            .txtSubdivision = rstSearchResults!Subdivision
            .dtpDatePaid = rstSearchResults!DatePaid
End With

However, when I check out the data, the District is incorrect, using the value one higher...do I just use -1 somewhere? Or is there a proper way to do this?

Thanks for your help,
Classic1
0
Classic1
Asked:
Classic1
  • 3
1 Solution
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Are you trying to load the RowSource of the combo?

mx
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
How about just:

 .cboDistrict = rstSearchResults!DistrictID

mx
0
 
Classic1Database AdministratorAuthor Commented:
Coo...that worked....I guess I was just making it harder on myself for some reason....if I was to change the DistrictID, would I have to use the ListIndex/ItemData property, since the combo box starts at 0, rather than 1? or if do I just reverse it when I want to save it?

rstSearchResults!DistrictID = .cboDistrict

Thanks,
Classic1
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
rstSearchResults!DistrictID = .cboDistrict

yes ... to retrieve the value currently showing in the combo box.

ListIndex/ItemData properties would *typically* (but not always) be used with a Multi-Select List box.

mx
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now