Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 4th, 2003, 02:34 AM
Authorized User
 
Join Date: Jun 2003
Location: Swansea, , United Kingdom.
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Default Listboxes In Access 97



Hi,

Nice to see everything is back up and running!! Looks great!!!

Does anyone now if it is possible to highlight rows in a listbox depending on certain critiria of an integer field?????

Many Thanks




Tim
__________________
Tim
Reply With Quote
  #2 (permalink)  
Old June 4th, 2003, 03:41 AM
Authorized User
 
Join Date: Jun 2003
Location: Goodlands, n/a, Mauritius.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to psychadelic
Default

Hi,

set the property MultiSelect to simple for your listbox [in access 97] and try something like this. The name of the listbox is List1

    Dim iCount As Integer

    For iCount = 0 To list1.ListCount - 1
        If **whatever test you want to do*** Then
            list1.Selected(iCount) = True
        End If
    Next iCount

You can use the Selected property in VB to determine if an item in a list box is selected.

I hope this will help you.
Reply With Quote
  #3 (permalink)  
Old June 6th, 2003, 04:25 AM
Authorized User
 
Join Date: Jun 2003
Location: Swansea, , United Kingdom.
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Psychadelic,

Thanks for the piece of code!! It works fine!!!!! BUT, before I decided to put this "Highlight" facility in users were able to click on any item in the list box and a subform would be displayed showing the full record details corresponding with their selection. Now that the List box is set to MultiSelect it breaks on the item double-click event.

The following code is behind the double click event :

Private Sub List23_DblClick(Cancel As Integer)

            Me.RecordsetClone.FindFirst "[ID] = " & Me!List23.Value
            Me.Bookmark = Me.RecordsetClone.Bookmark
            Me.Page12.SetFocus
            DoCmd.OpenQuery "Open Requests, acViewNormal"
            DoCmd.Close acQuery, "Open Requests"

End Sub

I thought about trying to chang the MultiSelect property to 0 as the first line of the Sub but not sure how to get it working. Any advice would be greatly appreciated!!

Many thanks


Tim
Reply With Quote
  #4 (permalink)  
Old June 6th, 2003, 06:19 AM
Authorized User
 
Join Date: Jun 2003
Location: Goodlands, n/a, Mauritius.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to psychadelic
Default

Hi again timmaher,

and I'm sure glad to help. When there are multiple selections in a list box, the value of the list box control will always be Null and you can't set the MultiSelect in run time mode...

But you can try this one when a user double click on the listbox :

   If list1.ListIndex <> -1 Then
       ' debug.print list1.ItemData(list1.ListIndex)
       ' put any code you want here and use list1.ItemData(list1.ListIndex) instead of list1.value
   End If

psychadelic
Reply With Quote
  #5 (permalink)  
Old June 6th, 2003, 08:25 AM
Authorized User
 
Join Date: Jun 2003
Location: Swansea, , United Kingdom.
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks again for you help,

Im a bit wet behind the ears when it comes to VBA, Is ther any way you could combine the suggestion you wrote :

If list1.ListIndex <> -1 Then
' debug.print list1.ItemData(list1.ListIndex)
' put any code you want here and use list1.ItemData(list1.ListIndex) instead of list1.value
End If

with the double click event i already have as im totally confused:

Private Sub List23_DblClick(Cancel As Integer)

Me.RecordsetClone.FindFirst "[ID] = " & Me!List23.Value
Me.Bookmark = Me.RecordsetClone.Bookmark
Me.Page12.SetFocus
DoCmd.OpenQuery "Open Requests, acViewNormal"
DoCmd.Close acQuery, "Open Requests"

End Sub


many thanks again



Tim
Reply With Quote
  #6 (permalink)  
Old June 9th, 2003, 03:17 AM
Authorized User
 
Join Date: Jun 2003
Location: Goodlands, n/a, Mauritius.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to psychadelic
Default

Hello,

Sorry for the delay I was off this week-end. I tried part of your code in a form bound to a table. On the double click event just add the following:
Code:
Private Sub list23_DblClick(Cancel As Integer)
   If me.list23.ListIndex <> -1 Then
      Me.RecordsetClone.FindFirst "[ID] = " & Me.list23.ItemData(Me.list23.ListIndex)          
      Me.Bookmark = Me.RecordsetClone.Bookmark
      Me.Page12.SetFocus
'     I've have not tried the last 2 lines but I guess it will be ok
      DoCmd.OpenQuery "Open Requests, acViewNormal"
      DoCmd.Close acQuery, "Open Requests"
   Else
      MsgBox "ID not in list!", vbExclamation + vbOKOnly
   End If
End Sub
You can now use the MultiSelect with this double click event.

Have a nice day,

psychadelic
Reply With Quote
  #7 (permalink)  
Old June 9th, 2003, 03:53 AM
Authorized User
 
Join Date: Jun 2003
Location: Swansea, , United Kingdom.
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks again for helping me out!!!!!!! REALLY appreciate your help with this.

Your code works great!1 Cant thank you enough!!!!!

:D

thanks again!!!

Tim
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Listboxes Sub-Listboxes and Table Linking MJB05 Access 4 September 20th, 2005 12:37 PM
Access 97 and a booking system narelleallen Access 2 June 24th, 2004 10:04 AM
Access 2000 to Access 97 happygv Access 5 April 23rd, 2004 10:06 AM
Access 97 Benwaa Access VBA 0 January 28th, 2004 02:37 PM
Migrating from access 97 to access 2000 Khalifeh Access 12 October 2nd, 2003 02:54 PM



All times are GMT -4. The time now is 08:37 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.