Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

For statement loop through combo boxes

Status
Not open for further replies.

access101

Programmer
Sep 4, 2010
68
US
I have a text box that auto populates when selecting an item in a combo box. The issue is i have 11 comboboxes that i want to list in the text box but only if it is <"s*". the code i have works but instead of going to the next line it overwrites my last combobox entry?

Dim r As Integer

For r = 1 To 11

If Me("V" & r) < "S *" Then
Me.Summary = Me.Sandwich.Form.cmbSandwich + vbCrLf & Me("V" & r) & vbCrLf
End If
Next r
 
Can we assume the combo boxes are named V1 through V11?
What is the name of the "text box that auto populates"?
What is Me.Sandwich.Form.cmbSandwich?

Are you building sandwiches with ingredients? If so, you should really provide some context so we can understand your question. If not, what is the real world application?

Duane
Hook'D on Access
MS Access MVP
 

How about...
Code:
Me.Summary = [b][red]Me.Summary &[/red][/b] Me.Sandwich.Form.cmbSandwich + vbCrLf & Me("V" & r) & vbCrLf



Randy
 
Randy,
I think there needs to be clarification on cmbSandwich since I believe this value should not appear in Summary multiple times.

Access101 should provide some additional information.

Duane
Hook'D on Access
MS Access MVP
 
How are ya access101 . . .
access101 said:
[blue]If Me("V" & r) < "S *" Then ...[/blue]
Me("V" & r) is obvious (Me(V1) thru Me(V11) ... but how are you qualify the comparsion [blue]< "S *"[/blue] ... or what is your intent?

[blue]Your Thoughts? . . .[/blue]


See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Putting aside the debate on Me.Sandwich :)

Code:
    Dim r As Integer
    Dim myString As String
    myString = ""

    For r = 1 To 11
        If Me("V" & r) < "S *" Then
            myString = myString & Me.Sandwich.Form.cmbSandwich + vbCrLf & Me("V" & r) & vbCrLf
        End If
    Next r
    Me.Summary = myString

your thoughts access101?

HTH << MaZeWorX >> "I have not failed I have only found ten thousand ways that don't work" <<Edison>>
 
thanks for the help i almost have it working but still need a little help.

i have a a continuous subform(sandwich) that has a combobox called (cmbsandwhich). on my main form i have a 8 comboboxes called "V" for veggies. the 1st option on my combobox is "select". So basically if it = select then my veggie summary should be null. if V = something then V + vbcrlf . the issue is it keeps duplicating the previous entry then adds the new entry to the bottom of the list.



 
ok take it back. just tried MazeWorX example and now it works! Thanks Everyone
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top