PC Review


Reply
Thread Tools Rate Thread

Data type-put in order of importance

 
 
Jane
Guest
Posts: n/a
 
      28th Oct 2008
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
 
Reply With Quote
 
 
 
 
Jeff Boyce
Guest
Posts: n/a
 
      28th Oct 2008
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" <(E-Mail Removed)> wrote in message
news:77D96802-67DB-4553-A666-(E-Mail Removed)...
> 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



 
Reply With Quote
 
Scott Lichtenberg
Guest
Posts: n/a
 
      28th Oct 2008
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" <(E-Mail Removed)> wrote in message
news:77D96802-67DB-4553-A666-(E-Mail Removed)...
> 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


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
The Importance of Cleaning Up Data David W. Fenton Microsoft Access 4 27th Oct 2007 10:53 PM
chart type affecting data order =?Utf-8?B?VG9tbXk=?= Microsoft Excel Charting 1 21st Sep 2007 06:15 PM
Text Data Type Sorting Order Sean Microsoft Access 1 11th Nov 2005 04:59 AM
importance of data validation and how it is implemented in Access =?Utf-8?B?Smh1bW1lbA==?= Microsoft Access Getting Started 2 15th Apr 2005 07:52 PM
best way to reverse bit order of data type ? Laszlo Szijarto Microsoft C# .NET 3 18th May 2004 05:01 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:30 AM.