HELP : "Invalid Paramater", when doing Tquery.Open, seems to not release resources

 Hi,

I am writing a piece of code that keeps on bombing with invalid paramater
everytime it tries to call Tquery.Open, but only once the specific procedure
has been called before.

Var Shft : String {paramater in function call}
 If (ShftWork_qry <> nil) then
  begin
   ShftWork_qry.Close;
   ShftWork_qry.Free;
  end;
 ShftWork_qry := TQuery.Create(Application.Owner);
 ShftWork_qry.Databasename := 'Timewizard';
 ShftWork_qry.SQL.Clear;
 ShftWork_qry.SQL.Add('Select * from ShftWork where ShiftCode =
"'+String(Shft)+'"');
 ShftWork_qry.Open;

This gets called a great deal of times in a rather complicated updating
procedure, and there are other similar functions that also get called. I
have spent 6hours messing around with an error message that makes no sense,
it also occurs at random, and seems to have something to do with the BDE
resources, since when I run it outside Delphi, it runs a while longer before
it bombs.

This is driving me nuts, any help would be GREATLY appreciated, the code has
been chopped up and redone many times to try and find a way around.

Please E-mail me if possible.
Thanx,
Johan