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 sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem sorting values with Command Button

Status
Not open for further replies.

0200050

Programmer
Jun 3, 2003
58
FI
Hi everybody!

Im using Microsoft Access 2000, and having a following problem.

First i'd like to tell something about the background of the issue.

I'm having a form, where is one textbox, called Seriesnumber. This textbox shows the records that come from a table. Above that textbox i have a Command button, called SortSeriesNumbers.

The purpose of this Command button would be to sort Seriesnumber's values.

Now let's get back to details.

Let's suppose we would have the following values in our table(and naturally in our form when previewing it):

Default settings display the alphabetical order of the table's records. After clicking once Command Button, the list changes its form(look at one click), and does the thing also after clicking the button twice(take a look at second click).

Default settings: One click(notice the change)

NA12313 NB*****
NA35451 NB*****
NB13523 NC*****
NB51243 NC*****
NC12451 ND*****
NC31235 NA*****
ND24114 NA*****

Second click(the NC comes up)

NC*****
NC*****
ND*****
NA*****
NA*****
NB*****
NB*****


So, by clicking Command Button, the order of the recordlist would change in this case like two records at a time.

Is this kind of a Sort Button difficult to program? If you would have a suggestion how to move on, i'd be really thankful to hear it.









 
Hello,
Question: how are or do you want to sort the Information. I don't understand how you sorted on the second click.
Have you thought about first click(get information) second click (Sort info...Fild visable = False)
Just a thought

Mark
 
Firstly don't base the form on a table. Always use a query, however that probably doesn't help you here.

Now you're not actually sorting here - not in the normal sense. You seem to be treating the data on the form as a cyclical set, circulating values from the end around to the begining. SQL doesn't do that naturally.

I honestly suggest you question why this is of any business benefit because I can't see a simple way of doing this.

In other database systems you tend to put data into arrays, or track them programmatically with cursors. You can do that sort of thing in Access but really its forte is it'll do that all automatically for you with dynasets.

 
Thank you for your posts Mark and Mike!

Answer to Mark: I've been trying to organize the records like this->

Default->A,B,C->
1. Click->B,C,A->
2. Click->C,A,B.

Answer to Mike: Yeah, this isnt actually SORTING, but it seems like that, when moving records on a form. The meaning of this is to be user-friendly mechanism.

A user could organize a large list of numbers(values) easier.

So do you Mike suggest that i should use dynasets? I'd like to hear about using them more.

I'm thinking i'll have to try queries next, they aren't that complicated, though it would be nice to do something "tougher".

However i've been asking this question before on other forums, and this function i received from one:

Code:
Global Hello As Long 'counter
Public Function Yo(Expression As String) As String
    Yo = Left(Expression, 1) & _
        Chr((Asc(Mid(Expression, 2, 1)) - Hello + 262535) Mod 26 + 65) & Mid(Expression, 3)
End Function

The guy who posted this said he is able to run queries with this, and they work well. I tried this and had no such success. I posted then a question to him, how to use this function with Command button. I'm now waiting his reply to this, if it ever arrives.

I tried to Call this function from Command button with no success. Now im wondering can i even call this at all???

Does anyone have an idea, how to use the function above with Command Button Click -event?





 
If you write a query then run it you get a datasheet view of the data. That view is a dynaset - I think that is just an Access term. Not only is the data sitting on your pc screen but Access is maintaining a link to the underlying table(s) that the data came from. If someone else changes or locks one of the records you are viewing, those actions will appear on your 'window'. Now, what I'm saying is if you want to do unusual things with your data you're going to have to program this yourself and thus lose this default Access functionality which actually saves you a lot of programming.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top