List Box err msg from Wizard

  • Thread starter Thread starter Sheldon
  • Start date Start date
S

Sheldon

I created a form with a list box on it based on a query,
SELECT [tblVendors].[VendorNumber], [tblVendors].
[VendorName]
FROM tblVendors
ORDER BY [tblVendors].[VendorName];

This works just fine. I also have a sub form attached to
the main form and I am trying to put a list box on this
form based on the query
SELECT tblContacts.*, tblContacts.VendorNumber
FROM tblContacts INNER JOIN tblVendors ON
tblContacts.VendorNumber = tblVendors.VendorNumber
WHERE (((tblContacts.VendorNumber)=[me].[lstVendorLkup].
[value]));

I can't even build the list box thru the wizard. I get
the following msg
"No value given for one or more required parameter."
My guess is that the query is wrong, but don't know why.

Any suggestions

Thanks
 
Sheldon said:
I created a form with a list box on it based on a query,
SELECT [tblVendors].[VendorNumber], [tblVendors].
[VendorName]
FROM tblVendors
ORDER BY [tblVendors].[VendorName];

This works just fine. I also have a sub form attached to
the main form and I am trying to put a list box on this
form based on the query
SELECT tblContacts.*, tblContacts.VendorNumber
FROM tblContacts INNER JOIN tblVendors ON
tblContacts.VendorNumber = tblVendors.VendorNumber
WHERE (((tblContacts.VendorNumber)=[me].[lstVendorLkup].
[value]));

I can't even build the list box thru the wizard. I get
the following msg
"No value given for one or more required parameter."
My guess is that the query is wrong, but don't know why.

The query engine has no idea what "[me]" is. The Me keyword can only be
used in VBA code, not in SQL. Change your query's SQL to provide a
fully qualified form reference; e.g.,

SELECT tblContacts.*
FROM tblContacts INNER JOIN tblVendors
ON tblContacts.VendorNumber = tblVendors.VendorNumber
WHERE tblContacts.VendorNumber =
[Forms]![NameOf Form]![lstVendorLkup];

You must substitute the name of your form where I said "NameOfForm" in
the above statement.

I removed the extra inclusion of tblContacts.VendorNumber in the select
list, since it's already include as part of tblContacts.*.
 
Back
Top