Quick Code Fix

Little_Man22

Registered User.
Local time
Today, 22:11
Joined
Jun 23, 2001
Messages
118
The problem with the code that I've written in a module to access the CurrentClientApplicationDataAgentInfo query is really ugly. It also only works if all of the fields are populated. If they aren't, I get the message: "Invalid Use of Null". I know that the code is bad and ideally a function would probably work great that says: 'IF the field is populated THEN use the varFieldvalue in the appropriate place as FDF_Ouput, ELSE varFieldvalue, " ".' I just don't know how to write something like this is VB language. Any ideas? This is the mess that I currently have:

Set rstClient = CurrentDb.OpenRecordset("CurrentClientApplicationDataAgentInfo")
While Not rstClient.EOF
Fdf_Output.FDFSetValue "AgentFulla", rstClient("AgentFulla"), False
Fdf_Output.FDFSetValue "AgentFullb", rstClient("AgentFullb"), False
Fdf_Output.FDFSetValue "AgentFirsta", rstClient("AgentFirsta"), False
Fdf_Output.FDFSetValue "AgentFirstb", rstClient("AgentFirstb"), False
Fdf_Output.FDFSetValue "AgentSeconda", rstClient("AgentSeconda"), False
Fdf_Output.FDFSetValue "AgentSecondb", rstClient("AgentSecondb"), False
Fdf_Output.FDFSetValue "SAa", rstClient("SAa"), False
Fdf_Output.FDFSetValue "SAb", rstClient("SAb"), False
rstClient.MoveNext
Wend
rstClient.Close
 
If you change:

Fdf_Output.FDFSetValue "AgentFulla", rstClient("AgentFulla"), False

to

Fdf_Output.FDFSetValue "AgentFulla", NZ(rstClient("AgentFulla")), False

it will write a zero length string rather than a null value to "AgentFulla". You can also set the optional 'valueifnull' argument to a specific value ie: Fdf_Output.FDFSetValue "AgentFulla", NZ(rstClient("AgentFulla"),"Hello World"), False

HTH
SteveA
 

Users who are viewing this thread

Back
Top Bottom