Re: Converting Queries to Code
From: Albert D. Kallal (pleasenonosspammkallal_at_msn.com)
Date: 04/08/04
- Next message: Bill Nichols: "Re: Converting Queries to Code"
- Previous message: Bill Nichols: "Converting Queries to Code"
- In reply to: Bill Nichols: "Converting Queries to Code"
- Next in thread: Bill Nichols: "Re: Converting Queries to Code"
- Reply: Bill Nichols: "Re: Converting Queries to Code"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 8 Apr 2004 00:59:21 -0600
"Bill Nichols" <anonymous@discussions.microsoft.com> wrote in message
news:D8339A94-7DC5-412B-842D-4C8CBEE7648B@microsoft.com...
> Good Morning all
>
> I have been following the recent articles about using pasting the sql
behind a query into
> a private sub. I have tried using this for an update query but with no
success. Does the
> syntax change at all ?
No, not really, but then again, the sql has to be right in the first place.
> I am running 2000 and my sub code is
>
> docmd.RunSql "UPDATE Completed SET Completed.Name = [ED]![Name]"
The problem with above that what record do you want from table Ed?
In other words, you are trying to set a record in table Completed, and you
are trying to get a value from table ED, but which value do you want from
table ed?
Further, you have to make sure the sql can distinguish between:
> docmd.RunSql "UPDATE Completed SET Completed.Name = 'hello' "
The above sql would set all the values in the field of "name" to hello. So,
what happens if you had a field called hello? In your case, you are trying
to set all values to "[ED]![Name]". I suspect, that this would be of no use,
and what you REALLY want is to fetched the value in the table called ed.
However, as mentioned, you need to specify WHAT record in table ed you want.
It is unlikely your above sql example runs ok in the query builder (get your
code working in the query builder first, and THEN try pasting it into your
code.
If for each record in table Completed, there is a single record from table
ED that has the same keyid, then you can do a join, and then run a update.
So, you need to identify what record from Completed you want to update (or
perhaps all records). And, you need to identity, or choose what value you
want from table ED.
-- Albert D. Kallal (MVP) Edmonton, Alberta Canada pleasenonoSpamKallal@msn.com http://www.attcanada.net/~kallal.msn
- Next message: Bill Nichols: "Re: Converting Queries to Code"
- Previous message: Bill Nichols: "Converting Queries to Code"
- In reply to: Bill Nichols: "Converting Queries to Code"
- Next in thread: Bill Nichols: "Re: Converting Queries to Code"
- Reply: Bill Nichols: "Re: Converting Queries to Code"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|