Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Combo boxes

Posted on 1998-12-03
2
Medium Priority
?
178 Views
Last Modified: 2010-05-03
My brain hurts... I want to populate a list/combo box with a bunch of values from a database, i.e a list of countries, which each have their own code ('FR' for France etc) and this code needs to stored in the record I'm currently editing. Is this possible using the intrinsic combo/list controls (The ItemData property only holds integers)? Whats the best way to do it? I do not want to use the DBList controls if possible.

Any suggestions welcomed.
0
Comment
Question by:mshire
2 Comments
 
LVL 3

Accepted Solution

by:
traygreen earned 150 total points
ID: 1448033
To display them both.....

do while not rs.eof
   cboCountries.AddItem rs!CountryCode & " - " & rs!Country
   rs.MoveNext
loop

Otherwise, keep a paralell array....
Private asCountryCodes() as string

Private Sub LoadCountries
   redim asCountryCodes(0)
   do while not rs.eof
      cboCountries.AddItem rs!Country
      asCountryCodes(Ubound(asCountryCodes)) = rs!CountryCode
      redim preserve asCountryCodes(Ubound(asCountryCodes) + 1)
      rs.MoveNext      
   loop
End Sub

Private Function GetCurrentCode() as String
   GetCurrentCode = asCountryCodes(cboCountries.ListIndex)
End Function
0
 
LVL 3

Expert Comment

by:jjmartin
ID: 1448034
Load the country names into the listbox, and load the country code into a parallel array.  Then when you want to save, you can access the corrosponding country code by the listbox index.

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question