Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Rows in combo
Masih Ostad Novin 
     
2 years ago
Hi. I want to force the user to pick up the first item ONLY in the combo box. So I wrote this code on the change event:

    Dim ListRows As Control
    Set ListRows = Forms!MainLotF!LotNrCombo
    With ListRows
    
    If ListRows = 1 Then
        Exit Sub
    Else
        MsgBox "Pick up the first item!"
        Me!LotNrCombo.Undo
    End If
    
    End With

It doesn't work.
Can you please help me.

Thanks
Masih Ostad Novin OP  @Reply  
     
2 years ago

Kevin Robertson  @Reply  
          
2 years ago
You need to check the ListIndex property of the Combo Box.
For example:

    If LotNrCombo.ListIndex <> 0 Then
        MsgBox "Pick up the first item!"
        LotNrCombo = Null
    End If
Kevin Robertson  @Reply  
          
2 years ago
Is there a reason why you can only select the first item?
Kevin Robertson  @Reply  
          
2 years ago
Do you need this code to run when a user types into the Combo Box?
If not I recommend using the After Update event instead.
Masih Ostad Novin OP  @Reply  
     
2 years ago
I have a form connected to the combo that I can close the items. All the items are the same product. So I want the user to pick up the first row in the combo and when that item is finished (closed) it will disappear from the combo (filtered: Closed=false) and next item will be available and so on...
Alex Hedley  @Reply  
           
2 years ago
If they can only pick the first item why even give them a combo in the first place, just pre select the one you want.
Masih Ostad Novin OP  @Reply  
     
2 years ago
Thanks Kevin, your code is working.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/6/2026 10:32:16 PM. PLT: 0s