Determine Highest Value in Unbound Listbox

Elana

Registered User.
Local time
Today, 13:39
Joined
Apr 19, 2000
Messages
232
Hi -

I have a form called "frmAddBldg" and a listbox on that form called "lstShowBldgs". The listbox displays all buildings associated with the master location that has been selected.

When a user is adding a building to a master location, I want the next available building number for that master location to display in the the bldg no field on the form.

What I've tried to do is use this code, but I keep getting the error "Too few parameters. Expected 1" when I hit this line in the code:

Set rst = dbs.OpenRecordset("SELECT [tblBuildings].[LocNo], [tblBuildings].[BldgNo] FROM tblBuildings WHERE ((([tblBuildings].[LocNo])=[forms]![frmaddbldg]![locno]));")

The problem seems to be how I am referring to the control on the form - if I place the loc number in the SELECT statement, it works fine... i.e., if I say 'locno = 190'. I'm doing something wrong with my reference.

HELP? Thanks much!
 
Last edited:
Try this way.

Set rst = dbs.OpenRecordset("SELECT [tblBuildings].[LocNo], [tblBuildings].[BldgNo] FROM tblBuildings WHERE [tblBuildings].[LocNo]=" & [forms]![frmaddbldg]![locno] & ";")
 
Thank you! I always seem to have trouble with those quotation marks...it works great now!
 

Users who are viewing this thread

Back
Top Bottom