By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,374 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

How to traverse a record in a row source property of a component

syedshaffee
P: 91
Hey people,
Expand|Select|Wrap|Line Numbers
  1.  
  2. How Can I Traverse Through a row source Property of a component
  3.  
is their any way to do the same? if yes please help
Sep 5 '12 #1

✓ answered by TheSmileyCoder

This code loops through a combobox (cmb_SelectSubSystem) on my form, printing the second column:
Expand|Select|Wrap|Line Numbers
  1. Private Sub btn_Traverse_Click()
  2.    Dim rs As DAO.Recordset
  3.    Set rs = Me.cmb_SelectSubSystem.Recordset
  4.    Dim strCombined As String
  5.    rs.MoveFirst
  6.    Do While Not rs.EOF
  7.       strCombined = strCombined & "," & rs.Fields(1)
  8.       rs.MoveNext
  9.    Loop
  10.    Set rs = Nothing
  11.    MsgBox strCombined
  12. End Sub
I dont really know if this could have any direct effect on the form itself, and what is selected in the combobox, but I dont think so.

Share this Question
Share on Google+
4 Replies


TheSmileyCoder
Expert Mod 100+
P: 2,321
You need to be more specific, which components are we talking about?

A combobox has .Recordset property, I suppose you could take a look at that.
Sep 5 '12 #2

syedshaffee
P: 91
i have a dropdown list and i want to traverse through that is it possible
Sep 5 '12 #3

TheSmileyCoder
Expert Mod 100+
P: 2,321
Probably, what are you looking for, what do you want to achieve?

Do you want to loop through all the records doing something, or looping through looking for something? I can't guess your requirements, and you are being extremely vague.
Sep 5 '12 #4

TheSmileyCoder
Expert Mod 100+
P: 2,321
This code loops through a combobox (cmb_SelectSubSystem) on my form, printing the second column:
Expand|Select|Wrap|Line Numbers
  1. Private Sub btn_Traverse_Click()
  2.    Dim rs As DAO.Recordset
  3.    Set rs = Me.cmb_SelectSubSystem.Recordset
  4.    Dim strCombined As String
  5.    rs.MoveFirst
  6.    Do While Not rs.EOF
  7.       strCombined = strCombined & "," & rs.Fields(1)
  8.       rs.MoveNext
  9.    Loop
  10.    Set rs = Nothing
  11.    MsgBox strCombined
  12. End Sub
I dont really know if this could have any direct effect on the form itself, and what is selected in the combobox, but I dont think so.
Sep 5 '12 #5

Post your reply

Sign in to post your reply or Sign up for a free account.