listbox and selection

icemonster

Registered User.
Local time
Today, 13:39
Joined
Jan 30, 2010
Messages
502
hi,

what is the best way to filter a form being opened from a listbox?

e.g

i have a listbox that has a column that can either be 1 or 2, what i want is, if it is 1, the listbox will open formA, but if it's 2. it will open formB, any suggestions?
 
In the after update event of the list box you would have code similar to this


Code:
IF listboxname=1 THEN
  docmd.openform "formA"
ELSE  
  docmd.openform "formB"
END IF

The above assumes that the column of the list box that holds the 1 or 2 is the bound column.
 
The code presented by jzwp22 will work fine so long as the column you wish to interrogate is the first column (ie. column number zero) for any other column use;

Code:
IF listboxname.Column([B][COLOR="Red"]X[/COLOR][/B])=1 THEN
  docmd.openform "formA"
ELSE  
  docmd.openform "formB"
END IF

Replace X with the column number that contains the info you wish to check. Remembering that the columns in a Listbox or combo, for that matter, are numbered from zero up
 
Yes you could use a Select case argument, it might look something like;
Code:
Select Case listboxname.Column([B][COLOR="Red"]X[/COLOR][/B])
     Case 1
          docmd.openform "formA"
     Case 2
          docmd.openform "formB"
End Select
 

Users who are viewing this thread

Back
Top Bottom