Hi to all,
just ran into a problem:
I wrote a function which works with several values collected on a
form. I thought it would be no problem, if the fields were empty,
because I made the function taking care of null-values.
Then I realized that I get an error when I try to pass the values like
that:
DatNext = A_Task_Next_Fct(Me![Task_ID],
Me![Task_Cycle],Me![Date_First, Me![Date_Last])
whenever one of the fields is empty.
What would be the correct way to handle this?
Thanks in advance.
Uwe 7 14683
Good Question. I will await a response from the experts, too. I think that
functions cannot have null parameters unless they are designated as
optional. I haven't experimented with optional parameters yet. What I do
instead is pass zero-length strings instead of nulls to the function, ie:
MyFunc(NZ(MyParameter,"")). I hope someone with more experience responds...
Fred Zuckerman
San Diego, CA, USA
"Uwe Range" <ur****@gmx.de> wrote in message
news:64**************************@posting.google.c om... Hi to all,
just ran into a problem: I wrote a function which works with several values collected on a form. I thought it would be no problem, if the fields were empty, because I made the function taking care of null-values.
Then I realized that I get an error when I try to pass the values like that:
DatNext = A_Task_Next_Fct(Me![Task_ID], Me![Task_Cycle],Me![Date_First, Me![Date_Last])
whenever one of the fields is empty.
What would be the correct way to handle this?
Thanks in advance.
Uwe
If the arguments are defined as Variants then you can pass Null values.
e.g.
Function A_Task_Next_Fct( _
varTask_ID as Variant, _
varTask_Cycle as Variant, _
varDate_First as Variant, _
varDate_Last as Variant)
You can also declare it as
Function A_Task_Next_Fct( _
varTask_ID, _
varTask_Cycle, _
varDate_First, _
varDate_Last)
As Variant is the default data type, but by declaring it fully you make it
clear that this is the datatype you want.
--
Terry Kreft
MVP Microsoft Access
"Uwe Range" <ur****@gmx.de> wrote in message
news:64**************************@posting.google.c om... Hi to all,
just ran into a problem: I wrote a function which works with several values collected on a form. I thought it would be no problem, if the fields were empty, because I made the function taking care of null-values.
Then I realized that I get an error when I try to pass the values like that:
DatNext = A_Task_Next_Fct(Me![Task_ID], Me![Task_Cycle],Me![Date_First, Me![Date_Last])
whenever one of the fields is empty.
What would be the correct way to handle this?
Thanks in advance.
Uwe
Uwe
You say that the function accepts nulls as parameters are you sure?
you haven't written it like A_Task_Next_Fct(myTask as long etc. etc)
If you are sure that it accepts nulls then is this what you are you
passing?
Does me![TaskID] default to 0 for instance?
It would help to know what the function does, what the error message
is & what line of code causes the error.
Neil ur****@gmx.de (Uwe Range) wrote in message news:<64**************************@posting.google. com>... Hi to all,
just ran into a problem: I wrote a function which works with several values collected on a form. I thought it would be no problem, if the fields were empty, because I made the function taking care of null-values.
Then I realized that I get an error when I try to pass the values like that:
DatNext = A_Task_Next_Fct(Me![Task_ID], Me![Task_Cycle],Me![Date_First, Me![Date_Last])
whenever one of the fields is empty.
What would be the correct way to handle this?
Thanks in advance.
Uwe
Neil,
He doesn't say the function accepts nulls, he says the function takes care
of nulls. The first is a subset of the second.
--
Terry Kreft
MVP Microsoft Access
"NeilAnderson" <ne***********@boroughmuir.edin.sch.uk> wrote in message
news:83**************************@posting.google.c om... Uwe
You say that the function accepts nulls as parameters are you sure? you haven't written it like A_Task_Next_Fct(myTask as long etc. etc) If you are sure that it accepts nulls then is this what you are you passing? Does me![TaskID] default to 0 for instance? It would help to know what the function does, what the error message is & what line of code causes the error.
Neil ur****@gmx.de (Uwe Range) wrote in message
news:<64**************************@posting.google. com>... Hi to all,
just ran into a problem: I wrote a function which works with several values collected on a form. I thought it would be no problem, if the fields were empty, because I made the function taking care of null-values.
Then I realized that I get an error when I try to pass the values like that:
DatNext = A_Task_Next_Fct(Me![Task_ID], Me![Task_Cycle],Me![Date_First, Me![Date_Last])
whenever one of the fields is empty.
What would be the correct way to handle this?
Thanks in advance.
Uwe
First of all thanks for the response to all.
I think I didn't explain it properly: The function does not accept
null values when they are passed to it. I can only handle null values
within the function (by checking with 'if not IsNull(myTask_id) ...').
Maybe Terry's suggestion to declare the variables as variant will
solve the problem. Otherwise I will have to test each value for null
values before passing it to the function and replace it with 0,
#1/1/1900#, "", ... which I would like to avoid.
Thanks again.
Uwe ne***********@boroughmuir.edin.sch.uk (NeilAnderson) wrote in message news:<83**************************@posting.google. com>... Uwe
You say that the function accepts nulls as parameters are you sure? you haven't written it like A_Task_Next_Fct(myTask as long etc. etc) If you are sure that it accepts nulls then is this what you are you passing? Does me![TaskID] default to 0 for instance? It would help to know what the function does, what the error message is & what line of code causes the error.
Neil ur****@gmx.de (Uwe Range) wrote in message news:<64**************************@posting.google. com>... Hi to all,
just ran into a problem: I wrote a function which works with several values collected on a form. I thought it would be no problem, if the fields were empty, because I made the function taking care of null-values.
Then I realized that I get an error when I try to pass the values like that:
DatNext = A_Task_Next_Fct(Me![Task_ID], Me![Task_Cycle],Me![Date_First, Me![Date_Last])
whenever one of the fields is empty.
What would be the correct way to handle this?
Thanks in advance.
Uwe
"Uwe Range" <ur****@gmx.de> wrote in message
news:64**************************@posting.google.c om... Hi to all,
just ran into a problem: I wrote a function which works with several values collected on a form. I thought it would be no problem, if the fields were empty, because I made the function taking care of null-values.
Then I realized that I get an error when I try to pass the values like that:
DatNext = A_Task_Next_Fct(Me![Task_ID], Me![Task_Cycle],Me![Date_First, Me![Date_Last])
whenever one of the fields is empty.
What would be the correct way to handle this?
Correct way? I dunno.
A way, make the arguments optional and don't pass them if
they are null.
"Uwe Range" <ur****@gmx.de> wrote in message
news:64**************************@posting.google.c om... First of all thanks for the response to all.
I think I didn't explain it properly: The function does not accept null values when they are passed to it. I can only handle null values within the function (by checking with 'if not IsNull(myTask_id) ...').
Maybe Terry's suggestion to declare the variables as variant will solve the problem. Otherwise I will have to test each value for null values before passing it to the function and replace it with 0, #1/1/1900#, "", ... which I would like to avoid.
A common way to handle this is to coalesce the null to a known value having
the correct data type, e.g. zero for numeric types, which you can then test
for in the function. Use the Nz function. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Ken Fine |
last post by:
I have a menu system that has nodes that can be opened or closed. In an
effort to make my code more manageable, I programmed a little widget tonight
that keeps track of the open/active item and...
|
by: Yangang Bao |
last post by:
I have a simple test program. It doesn't work. I want to know what is the
reason and how to
fix it. Maybe I should use template function to do it. But I don't know how.
Here is the simple...
|
by: _andrea.l |
last post by:
I'd like to write a function like:
function f(){ ... bla ...}
f_example(f);
function f_example($function_to_execute)
{...bla... $function_to_execute() ...bla....}
AND how to pass the...
|
by: Ronnie Smith |
last post by:
I am trying to pass a function (method) address to a user control to
associate with an event.
The small user control which sends events is contained in a larger user
control group which is in...
|
by: D. Shane Fowlkes |
last post by:
This may be a very basic question but it's something I've never done before.
I've looked at a couple of my favorite sites and books and can't find an
answer either. I can write a Function to...
|
by: Minfu Lu |
last post by:
I have a problem dealing with passing a function address to a COM callback. I
use this COM function for communicating to a hardware. My original project
was written in VB. I have converted it to...
|
by: _Mario.lat |
last post by:
Hallo,
I have a little question:
In the function session_set_save_handler I can pass the name of function
which deal with session.
In Xoops code I see the use of this function like that:
...
|
by: laredotornado |
last post by:
Hi,
I want to pass my function
myFunc('a', 'b', 'c')
as an argument to another function. However, this will not work
doStuff('x', 'y', myFunc('a', 'b', 'c'))
|
by: shalini jain |
last post by:
Hi,
I am facing the problem with eval function. I want to know how to pass a function in eval() when we have to create the function itself.
I would better explain my problem with the help of an...
|
by: iskhan |
last post by:
Is it possible that pass a function name as a argument in an other function?
e.g.
MainMenu($SubMenu)
{
//Main menu designing start
if(.......&&......||.......&&.......)
{
$this->$Submenu;...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |