2 parts - 1) Sorting & 2) Control array

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

1) Need to be able to sort short lists of items where it is inconvienent to
create a table abnd have the table sort the items and 2) Anyone have any work
arounds for creating an array of controls on a form? I used to do this with
Visual Basic, but Access will not allow this.

Thanks,
Bart
 
DaBartman said:
1) Need to be able to sort short lists of items where it is inconvienent to
create a table abnd have the table sort the items and

You need to tell us how you get your data. You could always put it in a list
box and sort the values there.

2) Anyone have any work
arounds for creating an array of controls on a form? I used to do this with
Visual Basic, but Access will not allow this.

Define your control names sequentially so you can access them with the ()
syntax:

Me("Text" & SomeIndex)

or:

Me.Text & SomeIndex

Then you can:

Dim i As Integer

For i = 1 to 10
Me("txtControlName" & i).Visible = True
Next
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
You can put the items in an array, and use your favourite sort technique on
the array. If you don't have a favourite technique, Randy Birch shows a few
in http://vbnet.mvps.org/code/sort/qscompare.htm (Obligatory warning:
Randy's site is aime at VB programmers. Because there are significant
differences in forms between VB and Access, not all of his code samples port
seamlessly into Access, but you can generally get an idea of what to do from
the VB code itself)

One common approach to simulating control arrays is to use a naming
convention, like txtArgument1, txtArgument2, txtArgument3 and so on. You can
then refer to the individual controls in a loop like:

Dim cltCurr As Control
Dim intLoop As Integer

For intLoop = 1 to 3
Set ctlCurr = Me.Controls("txtArgument" & intLoop)
' do your stuff
Next intLoop

It's not quite as neat for events, though: you'll have to create a generic
function that can rely on ActiveControl, and call that function in the
appropriate event of all of the controls in the pseudoarray.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top