Form problem with VBA code

narotosensei

Access Neophyte
Local time
Today, 13:59
Joined
Nov 14, 2009
Messages
12
This little problem has been bugging me all day. I have a form that has a listbox where you can click on buttons and change its row source to look at either reports or forms using MSysObjects. I also have 2 buttons that will either let you look at a report or look at a form. Now I have an OnLoad Event that makes sure that the listBox is in focus when you start the form, but when i click on the view form/report buttons it always has an error, but once I click on the listbox it works fine. I'm trying to set up a MsgBox that will set off if they don't have a form/report selected but I'm not sure how to go about it. Can anyone help me?
 
This type of thing?

Code:
  If Me.lstEmployees.ItemsSelected.Count = 0 Then
    MsgBox "Must select at least 1 employee"
    Exit Sub
  End If
 
Try

DoCmd.OpenForm "lstForms", acNormal
 
Whoops! Lol, I made the dumbest mistake, i used the wrong name to reference my listbox...
Thanks for the great help though :)
 
No problem, and welcome to the site by the way!
 

Users who are viewing this thread

Back
Top Bottom