CaptainBob007
Programmer
I'm working on a search form, and am trying to figure out how to format the data to populate a listbox the way I want.
Let's say I have a view that selects 4 fields: OwnID, OwnLast, OwnFirst, and Business.
I want to populate the list box with 2 fields, OwnID (which will not be visible), and Name. I'm trying to do this in a VBA statement. It works in simple form (ie when I dont try the IIF statement below). I'm trying to figure out how to make an equivalent of the below statement that works.
But it doesnt work, or I'm not doing it right, or (probably) both. Like I said if I replace the "IIF" statement with "[OwnLast]", it works perfectly, but I really need it to change depending on the Business field.
Would it be better to put this statement in the View (as another column perhaps) or in the Row Source statement of the list box? Is there anything noticably wrong with that statement?
Any help or advice would be greatly appreciated.
~Bob
Let's say I have a view that selects 4 fields: OwnID, OwnLast, OwnFirst, and Business.
I want to populate the list box with 2 fields, OwnID (which will not be visible), and Name. I'm trying to do this in a VBA statement. It works in simple form (ie when I dont try the IIF statement below). I'm trying to figure out how to make an equivalent of the below statement that works.
Code:
Me.listbox.RowSource = "SELECT OwnID,
IIF([Business]=False,[OwnLast]+', '+[OwnFirst],[OwnLast]) As Name
from myView
WHERE [OwnLast] LIKE '" & Me.LastName & "%'"
But it doesnt work, or I'm not doing it right, or (probably) both. Like I said if I replace the "IIF" statement with "[OwnLast]", it works perfectly, but I really need it to change depending on the Business field.
Would it be better to put this statement in the View (as another column perhaps) or in the Row Source statement of the list box? Is there anything noticably wrong with that statement?
Any help or advice would be greatly appreciated.
~Bob