Update Query with User-defined function?
- From: Greg Strong <NoJunk@NoJunk4UČ.com>
- Date: Fri, 30 Sep 2005 15:59:00 GMT
Hello All,
In an 'Update' query can you use user-defined functions in the 'Update
To' for the query? Either no or I'm missing something. See the
additional info below.
If I run a query as a select query it runs fine. The select query is as
follows:
SELECT tblOrderPrYr_Setup.ID,
RtnRndEstRevPY(tblOrderPrYr_Setup!EstRev,tblOrderPrYr_Setup!ID)
AS RevisedRev,
RtnRndEstRevPY([tblOrderPrYr_Setup]![EstCGS],[tblOrderPrYr_Setup]![ID])
AS RevisedCGS
FROM tblOrderPrYr_Setup;
If I change it to an update query on and either try to run it, save it,
or open into SQL I get an error message which reads:
'RtnRndEstRevPY([tblOrderPrYr_Setup]![EstCGS],[tblOrderPrYr_Setup]![ID])'
is not a valid name. Make sure that it does not include any invalid
characters or punctuation and that it is not too long.
The custom function is as follows:
Function RtnRndEstRevPY(dblEstRevPY As Variant, lngID As Variant)
'Randomize 'initialize random number generator
dblEstRevPY = Round(dblEstRevPY * ((0.94 - 0.9) * Rnd(lngID) + 0.9),
0)
RtnRndEstRevPY = dblEstRevPY
End Function
I originally had dblEstRevPY as a double and lngID as a long integer,
but I have changed them to variant. Still same error. It appears Access
does not see that I'm calling the 2 expressions RevisedRev and
RevisedCGS, respectively, when I change it to an update query.
Thanks!
--
Regards,
Greg Strong
.
- Follow-Ups:
- Re: Update Query with User-defined function?
- From: SilvrT
- Re: Update Query with User-defined function?
- From: Jerry Porter
- Re: Update Query with User-defined function?
- From: Bruce Rusk
- Re: Update Query with User-defined function?
- Prev by Date: Re: Strange Time-Formating Problem
- Next by Date: Re: RAM USAGE
- Previous by thread: Query base on a changing table
- Next by thread: Re: Update Query with User-defined function?
- Index(es):
Relevant Pages
|