A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Data type-put in order of importance



 
 
Thread Tools Display Modes
  #1  
Old October 28th, 2008, 05:08 PM posted to microsoft.public.access
Jane
external usenet poster
 
Posts: 464
Default Data type-put in order of importance

Hi all,

I am trying to create a survey with access, and I have a question in it
which states " Put these 5 options in order of importance" then I have 5
options, but how can I do this in access?

Any help would be greatly appreciated

Thanks
  #2  
Old October 28th, 2008, 05:55 PM posted to microsoft.public.access
Jeff Boyce
external usenet poster
 
Posts: 8,621
Default Data type-put in order of importance

Jane

Unless you let us in on how YOU put the items in "order of importance",
we're not too likely to be able to guess...

Are you working in a form? Are you working with an option group control?
Give us a bit of context...

Regards

Jeff Boyce
Microsoft Office/Access MVP

"Jane" wrote in message
...
Hi all,

I am trying to create a survey with access, and I have a question in it
which states " Put these 5 options in order of importance" then I have 5
options, but how can I do this in access?

Any help would be greatly appreciated

Thanks



  #3  
Old October 28th, 2008, 07:06 PM posted to microsoft.public.access
Scott Lichtenberg[_2_]
external usenet poster
 
Posts: 37
Default Data type-put in order of importance

Jane,

Here's one way to do it. I'm sure there are other ways, some of which will
be easier and more efficient.

Start with a table to hold your option and its rank. Rank should be single
or decimal data type.

Put a list box on your form bound to the table. Your rowsource would be
something like "SELECT Option from tblOptions ORDER BY Rank".

Put two command buttons next to the list box, one to move an option up, the
other to move it down. When the user clicks the button, open a recordset,
move to the selected item in the listbox, and increase or decrease it's
rank. In the code below, I am decreasing the rank by 1.5. This would
effectively move the option upward in preference. You have to
increase/decrease the rank by enough to make the option lower/higher than
the next value.

Dim db as database
Dim rs as Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT * FROM MyTable", dbOpenDynaset)

rs.FindFirst "Option = '" & Me!MyListBox & "'" 'I'm assuming option
is text
rs.Edit
rs!Rank = rs!Rank - 1.5
rs.Update
rs.Close

The next step will be to resequence your options so they are again ranked 1
to 5. This will allow the user to change the rankings as many times as
he/she needs to.

Dim x as integer
Set rs = db.OpenRecordset("SELECT * FROM MyTable ORDER BY Rank",
dbOpenDynaset)
Do While Not rs.EOF
x = x + 1
rs.Edit
rs!Rank = x
rs.Update

rs.MoveNext
Loop
rs.Close

Set rs = Nothing
Set db = Nothing

Finally, requery the listbox to redisplay the options in the correct order.

There are probably better ways to do this. You could use an array rather
than a table to hold your data. You might be able to manipulate the
ListIndex property of the list box to move your options around. You can
even create a function that acts as the RowSourceType of the list box which
would allow you to manipulate the items.

Hope this helps.


"Jane" wrote in message
...
Hi all,

I am trying to create a survey with access, and I have a question in it
which states " Put these 5 options in order of importance" then I have 5
options, but how can I do this in access?

Any help would be greatly appreciated

Thanks


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:23 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.