
Problem with SELECT statement
Quote:
>I have some code in the onclick event that looks like
>this:
>_____________________________________________________
>Set db = CurrentDb
>Set rsREGIONS = db.OpenRecordset("SELECT * " & _
>"FROM [Regions]" & _
>"WHERE [Region]=Me!Region")
>Set valRegionDistributionCode = rsREGIONS![Region
>Distribution Code]
>______________________________________________________
>[Regions] is a table with a field "Region" and a
>field "Region Distribution Code".
>Me!Region refers to a combo box on the current form.
>When I click the command button that executes this code, I
>get an error saying Run Time Error 3061 Too Few
>Parameters. Expected 1.
>I'm trying to get the [Region] field on the current form
>to match up with the [Region] field in a table. Any
>thoughts?
You have to place the value of the combo in the query, not a
reference to it (the
VBA enviornment can't deal with it the
way the QBE or a Form/Report can).
The query you posted is also missing a space before the
Where clause. Try this:
"SELECT * " & _
"FROM [Regions] " & _
"WHERE [Region]= " & Me!Region
--
Marsh
MVP [MS Access]