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!

dlookup or ?

Status
Not open for further replies.

tuxalot

Technical User
Sep 5, 2002
34
US
I have a 2 column table that looks like such

1 apple
2 banana
3 orange
4 tomato
5 strawberry

This table could have up to 15 rows but may have as few as 3.

On my main form I have an option group with 15 toggles and values of 1-15. I would like to make the togglebuttons.visible = false for rows 6-15 in the above example. I guess I could run 15 dlookups but I was wondering if there was a better solution.

I would very much appreciate any help you can provide.
 
How are ya skywaz . . .

A [blue]listbox[/blue] or [blue]combobox[/blue] would be perfect for this and wouldn't require any code to hide values.

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

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Hi Ace. I had thought of that, but I like the simplicity of a single click interface. In this project clicking a choice in the option group loads a query that sets the recordset for a subform. So a user can quickly move between sections with a single click. Understood that a listbox can offer this same functionality but it doesn't look as cool as a series of buttons.

How about a for each loop, where a variable is incremented representing the criteria for a dlookup? Still would have 15 dlookups, and would need to deal with nulls, but the code would be cleaner.

Access is very new to me and I can see it in me head, but struggle with coding at times.

Thanks again. Please let me know if this for each loop is way off base.
 

How about something like this? (not tested)
You need to put a value in the tag property.
Code:
Dim intcount As Integer
Dim ctl As Control
intcount = DCount("Key", "File1")
For Each ctl In Me
    If ctl.Type = acOptionButton Then
        If ctl.Tag > intcount Then
            ctl.Visible = False
        Else
            ctl.Visible = True
        End If
    End If
Next ctl


Randy
 
Thanks Randy! Slight change to the code, and it's working:

Dim intcount As Integer
Dim ctl As Control
intcount = DCount("*", "tblSections")
For Each ctl In Me.Controls
If TypeOf ctl Is ToggleButton Then
If ctl.Tag > intcount Then
ctl.Visible = False
Else
ctl.Visible = True
End If
End If
Next ctl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top