Problem with SQL statement in VBA Procedure

  • Thread starter Thread starter Daveo
  • Start date Start date
D

Daveo

Hi there,

When I run the following code I get a "Run-time error 3061. Too few
parameters. Expected 1":

strAssetType = CurrentDb.OpenRecordset("SELECT LU_assetTypes.type" & _
" FROM LU_assetTypes WHERE LU_assetType.assetTypeID = " &
Me.[assetType]).Fields(0)

I'm confused because I also have the following code in the line
preceding it, which works fine:

strAssetCat = CurrentDb.OpenRecordset("SELECT
LU_assetCategories.category" & _
" FROM LU_assetCategories WHERE LU_assetCategories.assetCategoryID =" &
Me.assetCat).Fields(0)

Both statements are the same, except for table and field name changes
(I've double checked them).

Can anyone shed any light please?

Many thanks - David
 
if you've pasted in the exact expression directly from the VBA Editor
window, then i'd say the problem may be that the table name isn't typed
consistently:

strAssetType = CurrentDb.OpenRecordset("SELECT LU_assetTypes*.type" & _
" FROM LU_assetTypes* WHERE LU_assetType*.assetTypeID = " &
Me.[assetType]).Fields(0)

the asterisks i added show two different spellings being used:
LU_assetTypes, and LU_assetType. try fixing the incorrect spelling (but
don't use the asterisks i added!)

hth
 
Back
Top