Results 1 to 6 of 6

Thread: Weird QueryDef Error

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2000
    Posts
    26
    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?

  2. #2
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    Can you post the SQL for your querydef?
    "It's cold gin time again ..."

    Check out my website here.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Aug 2000
    Posts
    26

    ..here is teh SQL

    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]));

  4. #4
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    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)

    "It's cold gin time again ..."

    Check out my website here.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Aug 2000
    Posts
    26

    still no go

    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

  6. #6
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    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.

    "It's cold gin time again ..."

    Check out my website here.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width