PDA

Click to See Complete Forum and Search --> : Weird QueryDef Error


ncage
Aug 12th, 2000, 01:15 PM
I have a wierd error when im trying to run an update query on an access database here is the line where im having a problem
.QueryDefs("qryRecipeUPD").Parameters("[txtDirections]").Value = trim$(txtDirections)

i get an error that tells me an invalid use of property

i tried removing the trim$() and tried it again and it still wouldn't work

finally i tried just putting in a constant string "hi" and it worked.

When i look at the value of the query def paramater when im in debug mode it shows as empty which lead me to believe it was a variant. So i tried to do a cvar() and just a plain trim() and neither would work. Does anyone know what is going on?

BruceG
Aug 12th, 2000, 07:30 PM
Can you post the SQL for your querydef?

ncage
Aug 13th, 2000, 12:04 AM
UPDATE tblRecipe SET tblRecipe.RecipeName = [Recipe Name], tblRecipe.RecipeCategoryID = [Recipe CategoryID], tblRecipe.RecipeCuisineID = [Recipe CusineID], tblRecipe.Directions = [txtDirections], tblRecipe.Ingrediants = [txtIngrediants]
WHERE (((tblRecipe.RecipeID)=[Recipe ID]));

BruceG
Aug 13th, 2000, 09:34 AM
It may be getting confused with the name "txtDirections". Try using the .Text property explicitly, i.e.:
.QueryDefs("qryRecipeUPD").Parameters("[txtDirections]").Value = trim$(txtDirections.Text)

ncage
Aug 13th, 2000, 12:59 PM
I tried doing the txtDirections.txt and it still does not work...i even tried going so far as converting the datbase to access 97 database and using dao 3.5 instead of 3.6 thinking there might be some kind of bug...but it didn't work. here is my exact code where im doing my query def stuff

With goDatabase
.QueryDefs("qryRecipeUPD").Parameters("[uRecipeID]").Value = RecipeID
.QueryDefs("qryRecipeUPD").Parameters("[uRecipeCategoryID]").Value = cboCategory.ItemData(cboCategory.ListIndex)
.QueryDefs("qryRecipeUPD").Parameters("[uRecipeCuisineID]").Value = cboCuisine.ItemData(cboCuisine.ListIndex)
.QueryDefs("qryRecipeUPD").Parameters("[uDirections]").Value = "hi" 'Trim(txtDirections.Text)
.QueryDefs("qryRecipeUPD").Parameters("[uIngrediants]").Value = Trim$(txtIngrediants.Text)
.QueryDefs("qryRecipeUPD").Parameters("[uRecipeName]").Value = Trim$(txtRecipeName)
.Execute ("qryRecipeUPD")
End With

as you can see above i comented out a line and put "hi" in place of trim(txtdirections.txt)..it was originally using the Trim$() i can't seem to get it working no matter what i do. I even deleted my access query and created a new on thinking maybe something was wrong with the query...do you have any other ideas on what could be going on?

thanks
ncage

BruceG
Aug 13th, 2000, 04:28 PM
This is a toughy to be sure. Given your VB code, I would make sure that the Access query looks like this:

PARAMETERS uRecipeName TEXT, uRecipeCategoryID LONG,
uRecipeCuisineID LONG, uDirections TEXT, uIngrediants TEXT,
uRecipeID LONG;
UPDATE tblRecipe SET tblRecipe.RecipeName = uRecipeName, tblRecipe.RecipeCategoryID = uRecipeCategoryID, tblRecipe.RecipeCuisineID = uRecipeCusineID, tblRecipe.Directions = uDirections, tblRecipe.Ingrediants = uIngrediants WHERE (((tblRecipe.RecipeID) = uRecipeID));

It seems like you're doing things the right way, nothing wrong leaps out at me.