[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 709
  • Last Modified:

how to check in vba access 2010 in a form if a list box is empty

hi

i have a list box (with the name outputlistbox) that the row source is activated by a recordset and i want that a certain  command button will work only if the list box is not empty and i wrote this code:
 If IsNull(Me.OutPutListbox.RowSource) Or Me.OutPutListbox = "" Then Exit Sub
but the computer allways recognize the list box that it's not empty and it's not exit the sub
why is this?
0
bill201
Asked:
bill201
1 Solution
 
Rey Obrero (Capricorn1)Commented:

first, what is the RowSource of the listbox? post it here

you can use dcount() to check if rowsource will have records return or open it as recordset.
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Also, you only need this:

 If Me.OutPutListbox = ""

because the RowSource property is a String value, and will never be Null ... only and Empty String  ""

mx
0
 
bill201Author Commented:
yes you are right i can make a dcount
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Tackle projects and never again get stuck behind a technical roadblock.
Join Now