Hi All,
I have started tearing my hair out over this problem!
I am pulling some data from a table and passing it as variables into a function in Access. One of the variables I'm passing through can be Null, so to avoid trying to pass a Null value to a function as a string (which I gather Access wouldn't like) I created an IIF function inside the parameters so if the value was null, it passed the string "NULLDEPOT" into the function, and I dealt with it inside the function.
No matter HOW I try (stacked queries, new variables, taking the IIF out of the function parameters and creating it earlier)...I always get an "#Error" value returned. Even when I set a breakpoint at the top of the function, Access won't trip it if that value was ever Null, however every other value works fine?!
I'll include my code below:
Query code: - VendorCode: Supplier("13",[AGCECOM],[PMC],[Supplier Number],IIf([DepotID] Is Null,"NULLDEPOT",[DepotID]))
VB Function Code: - Public Function Supplier(OrigDep As String, AgCE As String, PMC As String, VendNum As String, MainDepot As String) As String
-
Dim TempSupplier As String
-
-
...snip...
-
-
ElseIf OrigDep = "13" Then
-
If MainDepot = "NULLDEPOT" Then
-
TempSupplier = "N"
-
ElseIf MainDepot = "13" Then
-
TempSupplier = VendNum
-
Else
-
TempSupplier = "1400000"
-
End If
-
-
...snip...
-
-
Else
-
TempSupplier = "N"
-
End If
-
-
' AgCE and PMC Logic Final Override
-
If AgCE = "CE" Or PMC = "V" Then
-
TempSupplier = "ZZZ"
-
End If
-
-
' Return string
-
Supplier = TempSupplier
-
-
End Function
-
Please HELP!!!
4 10272
Hi All,
I have started tearing my hair out over this problem!
I am pulling some data from a table and passing it as variables into a function in Access. One of the variables I'm passing through can be Null, so to avoid trying to pass a Null value to a function as a string (which I gather Access wouldn't like) I created an IIF function inside the parameters so if the value was null, it passed the string "NULLDEPOT" into the function, and I dealt with it inside the function.
No matter HOW I try (stacked queries, new variables, taking the IIF out of the function parameters and creating it earlier)...I always get an "#Error" value returned. Even when I set a breakpoint at the top of the function, Access won't trip it if that value was ever Null, however every other value works fine?!
I'll include my code below:
Query code: - VendorCode: Supplier("13",[AGCECOM],[PMC],[Supplier Number],IIf([DepotID] Is Null,"NULLDEPOT",[DepotID]))
VB Function Code: - Public Function Supplier(OrigDep As String, AgCE As String, PMC As String, VendNum As String, MainDepot As String) As String
-
Dim TempSupplier As String
-
-
...snip...
-
-
ElseIf OrigDep = "13" Then
-
If MainDepot = "NULLDEPOT" Then
-
TempSupplier = "N"
-
ElseIf MainDepot = "13" Then
-
TempSupplier = VendNum
-
Else
-
TempSupplier = "1400000"
-
End If
-
-
...snip...
-
-
Else
-
TempSupplier = "N"
-
End If
-
-
' AgCE and PMC Logic Final Override
-
If AgCE = "CE" Or PMC = "V" Then
-
TempSupplier = "ZZZ"
-
End If
-
-
' Return string
-
Supplier = TempSupplier
-
-
End Function
-
Please HELP!!!
Try using Nz() instead of the iif function.
Try using Nz() instead of the iif function.
Already tried that Rabbit and I get the same error.
Any other suggestions?
Already tried that Rabbit and I get the same error.
Any other suggestions?
Nevermind, found my own answer. All inbound function variables should be declared as Variants and then deal with the NZ() function inside my custom function.
Excellent. Always better when the PO finds their own answer.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Oleg |
last post by:
I am trying to send one of the parameters of stored
procedure having a null value. The parameter is of type
blob. I declare it in code like 'new OleDbParameter
("p_sigPicture",...
|
by: Robb Gilmore |
last post by:
Hello,
We have a C#.NET app which is calling a Java webservice. We use the wsdl
file exportted from the java webservice to create our web-reference in Visual
Studio. We are able to create the...
|
by: Michael Tissington |
last post by:
I have a DLL written in C++ and I'm calling it from C#
One of the parameters for a function in the DLL is a DATE value or NULL.
How do I pass NULL to my DLL from C#?
--
Michael Tissington...
|
by: Dana |
last post by:
I am using the XMLTextWriter to build an XML string and pass it to the
XMLDocument. When I get the data from SQL Server, some of the values
passed to the XML are NULL in the database. When I try...
|
by: PK |
last post by:
Hi, I have an application that opens a Crystal report document and
passes in a value to a parameter in the report (pointing to an Oracle
DB). However, if I want to pass a "null" value to retrieve...
|
by: David Shorthouse |
last post by:
Hey folks,
I am attempting to pass null as the input value from a series of
textboxes if the user does not input a value prior to submit. To try and do
this, I am using a vbscript function on...
|
by: fniles |
last post by:
I am accessing MS Access db with tblA whose column UNABLE can have NULL
value. When I access UNABLE whose value is null, I got an error "
Run-time exception thrown : System.InvalidCastException -...
|
by: kumar.senthil |
last post by:
Hi,
I'm using XmlSerializer to create an object from the XML string. I
would like to know whether I can get a null value for an empty XML
element.
Actually the XmlSerializer assigns "" (empty...
|
by: qwedster |
last post by:
Folk!
How to programattically check if null value exists in database table (using stored procedure)?
I know it's possble in the Query Analyzer (see last SQL query batch statements)?
But how...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |