multiple problems with listbox on form
I'm a novice using Access 2003, and I've got a form bound to a query
called AlphaAcctQ (which alphabetizes the account names from a table -
AccountT). On the form is an unbound list box which displays the account
names from the query and returns the numerical AcctID for the selected
account.
There is command button on the form, "CreateInv." When clicked, I'd like
it to display an error message if nothing is selected in the listbox, but
when I write
Call MsgBox("AcctList.Value = " & AcctList.Value, vbOKOnly)
If AcctList.Value = Null Then
Call MsgBox("You must select an account first.", vbOKOnly)
'Else
'If subform returns no values Then
'Call MsgBox with another error code
'End If
'run an append query
End If
...then I get a box that says "AcctList.Value =" (which was a test to show
me what the AcctList listbox was returning as a value) but nothing else
happens. I even set the default value of AcctList to "=Null" in its
properties, but that didn't change anything.
I've commented out the structure of some code I haven't written yet,
because that's supposed to give me an error message if there aren't values
in the subform, and if I can't even figure out how to generate an error
message if the listbox has nothing selected in it, then I have no idea how
to even start that code.
So, how can I write an IF statement for if nothing is selected in the
listbox? What about another IF statement for if the subform (which is
based on another query that selects invoice items fitting the criterion of
the selected account in the AcctList listbox in the main form)?
Thanks.
No comments:
Post a Comment