Stukmeister said:
I am new to Access sql, so this may be a dumb question ... but is there a way
to load "work" or "temp" fields?
Stukmeister,
Not in an SQL statement. No.
Can I load say "waddr1" with the info once
and then use waddr1 for "Address 1" and "Address Key".
It sounds to me like you'd like to run some VBA code to handle
intermediate data, but that'll require some DAO know-how.
A simpler course would be to take those gigantic IIF statements, and
hide them behind VBA.
UPDATE ??
SET D.[Address 1] =
IIf(( [address 1] Is Null
or [address 1] like "addrs"
or [address 1] like "address")
And [country] = "UN1"
,"xxx"
,[address 1])
,D.City = IIf( [city] Is Null
And [country] = "UN1"
,"xxx"
,[city])
,D.State = IIf( [state] Is Null
And [country] = "UN1"
,"xxx"
,[state])
,D.ZIP = IIf( [zip] Is Null
And [country] = "UN1"
,"xxx"
,[zip])
,D.[Address Key] = ([state] & "-" & [city] & "-" & [address 1])
(Note: I'm using *really* trumped up function and variable names,
here.)
Air Code:
Public Function LoadCity(strCity as String _
,strCountry as String) AS String
dim strLoadCity AS String
strLoadCity = IIf(IsNull(strCity) AND _
strCountry = "UN1"
,"xxx"
,strCity)
LoadCity = strLaod
End Function
And etc. for State, Zip, and [Address 1].
UPDATE ??
SET [Address1] = LoadAddress1([address 1], [country])
,City = LoadCity([city], [country])
,State = LoadState([state], [country])
,ZIP = LoadZip([zip], [country])
,[Address Key] = LoadState([state], [country]) & "-" &
LoadCity([city], [country]) & "-" &
LoadAddress1([address 1], [country])
There, that looks much better, should do the same thing (it's
untested, of course, so please check it out). This will be slower,
though.
Sincerely,
Chris O.