function

P

patti

Can someone explain what is happening with this modGeneral module? ? I have
hopefully just pulled out the necessary info.

Report “on open†event:

Public Function fnPopulateTable_2()
Dim strSQL As String
......
strSQL = "SELECT…..fnGetPO([ON Order PO Info].[m1 po],[ON Order PO Info].[m2
PO],[ON Order PO Info].[m3 po],[ON Order PO Info].[m4 po]……


modGeneral:


Public Function fnGetPO(po1, po2, po3, po4) As String
Dim strPO As String

If Not IsNull(po1) Then
strPO = po1
Else
If Not IsNull(po2) Then
strPO = po2
Else
If Not IsNull(po3) Then
strPO = po3
Else
If Not IsNull(po4) Then
strPO = po4
Else
strPO = "None"
End If
End If

End If
End If

fnGetPO = strPO
End Function


What is the mod looking at for “IsNull�

Thanks.

patti
 
D

Douglas J. Steele

The function accepts four values. If there's a value for the first
parameter, the function returns that value. If the first parameter has a
Null value, but there is a value for the second parameter, the function
returns that value. If thefirst and second parameters both have Null values,
but there's a value for the third parameter, the function returns that
value. If the first, second and third parameters all have Null values, but
there's a value for the fourt parameter, the function returns that value. If
all of the first, second, third and fourth parameters have Null values, the
function returns the string "None".
 
P

patti

Thanks for the speedy reply.

Where is the function looking for the value?
Is it looking at [ON Order PO Info].[m1 po], etc? Is that what becomes the
"strPO"?



Douglas J. Steele said:
The function accepts four values. If there's a value for the first
parameter, the function returns that value. If the first parameter has a
Null value, but there is a value for the second parameter, the function
returns that value. If thefirst and second parameters both have Null values,
but there's a value for the third parameter, the function returns that
value. If the first, second and third parameters all have Null values, but
there's a value for the fourt parameter, the function returns that value. If
all of the first, second, third and fourth parameters have Null values, the
function returns the string "None".

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


patti said:
Can someone explain what is happening with this modGeneral module? ? I
have
hopefully just pulled out the necessary info.

Report "on open" event:

Public Function fnPopulateTable_2()
Dim strSQL As String
......
strSQL = "SELECT...fnGetPO([ON Order PO Info].[m1 po],[ON Order PO
Info].[m2
PO],[ON Order PO Info].[m3 po],[ON Order PO Info].[m4 po]..


modGeneral:


Public Function fnGetPO(po1, po2, po3, po4) As String
Dim strPO As String

If Not IsNull(po1) Then
strPO = po1
Else
If Not IsNull(po2) Then
strPO = po2
Else
If Not IsNull(po3) Then
strPO = po3
Else
If Not IsNull(po4) Then
strPO = po4
Else
strPO = "None"
End If
End If

End If
End If

fnGetPO = strPO
End Function


What is the mod looking at for "IsNull"?

Thanks.

patti
 
D

Douglas J. Steele

Your SQL is invoking the function through the inclusion of

fnGetPO([ON Order PO Info].[m1 po],[ON Order PO Info].[m2 PO],[ON Order PO
Info].[m3 po],[ON Order PO Info].[m4 po])

That means that the four fields from the table being passed to the function
are [m1 po], [m2 po], [m3 po] and [m4 po]. Since those fields are being
passed in that order to the function, within the function, po1 refers to the
value passed from [m1 po], p02 refers to the value passed from [m2 po], p03
refers to the value passed from [m3 po] and p04 refers to the value passed
from [m4 po]. strPO is simply an internal variable within the function. Once
it's been assigned a value, the function is assigned that value through the
statement

fnGetPO = strPO

so that's what gets back to the query.

The names used within functions really have nothing to do with what's being
passed to the function. The function could just as easily have been written
as either of the following and it would still accomplish exactly the same
thing.

Public Function fnGetPO(w, x, y, x) As String
Dim a As String

If Not IsNull(w) Then
a = w
Else
If Not IsNull(x) Then
a = x
Else
If Not IsNull(y) Then
a = y
Else
If Not IsNull(z) Then
a = z
Else
a = "None"
End If
End If
End If
End If

fnGetPO = a

End Function

or

Public Function fnGetPO(w, x, y, x) As String
Dim a As String

If Not IsNull(w) Then
a = w
ElseIf Not IsNull(x) Then
a = x
ElseIf Not IsNull(y) Then
a = y
ElseIf Not IsNull(z) Then
a = z
Else
a = "None"
End If

fnGetPO = a

End Function


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


patti said:
Thanks for the speedy reply.

Where is the function looking for the value?
Is it looking at [ON Order PO Info].[m1 po], etc? Is that what becomes the
"strPO"?



Douglas J. Steele said:
The function accepts four values. If there's a value for the first
parameter, the function returns that value. If the first parameter has a
Null value, but there is a value for the second parameter, the function
returns that value. If thefirst and second parameters both have Null
values,
but there's a value for the third parameter, the function returns that
value. If the first, second and third parameters all have Null values,
but
there's a value for the fourt parameter, the function returns that value.
If
all of the first, second, third and fourth parameters have Null values,
the
function returns the string "None".

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


patti said:
Can someone explain what is happening with this modGeneral module? ? I
have
hopefully just pulled out the necessary info.

Report "on open" event:

Public Function fnPopulateTable_2()
Dim strSQL As String
......
strSQL = "SELECT...fnGetPO([ON Order PO Info].[m1 po],[ON Order PO
Info].[m2
PO],[ON Order PO Info].[m3 po],[ON Order PO Info].[m4 po]..


modGeneral:


Public Function fnGetPO(po1, po2, po3, po4) As String
Dim strPO As String

If Not IsNull(po1) Then
strPO = po1
Else
If Not IsNull(po2) Then
strPO = po2
Else
If Not IsNull(po3) Then
strPO = po3
Else
If Not IsNull(po4) Then
strPO = po4
Else
strPO = "None"
End If
End If

End If
End If

fnGetPO = strPO
End Function


What is the mod looking at for "IsNull"?

Thanks.

patti
 
P

patti

Thank you very much for explaining this to me and for the alternative coding.
You made it make sense.
Douglas J. Steele said:
Your SQL is invoking the function through the inclusion of

fnGetPO([ON Order PO Info].[m1 po],[ON Order PO Info].[m2 PO],[ON Order PO
Info].[m3 po],[ON Order PO Info].[m4 po])

That means that the four fields from the table being passed to the function
are [m1 po], [m2 po], [m3 po] and [m4 po]. Since those fields are being
passed in that order to the function, within the function, po1 refers to the
value passed from [m1 po], p02 refers to the value passed from [m2 po], p03
refers to the value passed from [m3 po] and p04 refers to the value passed
from [m4 po]. strPO is simply an internal variable within the function. Once
it's been assigned a value, the function is assigned that value through the
statement

fnGetPO = strPO

so that's what gets back to the query.

The names used within functions really have nothing to do with what's being
passed to the function. The function could just as easily have been written
as either of the following and it would still accomplish exactly the same
thing.

Public Function fnGetPO(w, x, y, x) As String
Dim a As String

If Not IsNull(w) Then
a = w
Else
If Not IsNull(x) Then
a = x
Else
If Not IsNull(y) Then
a = y
Else
If Not IsNull(z) Then
a = z
Else
a = "None"
End If
End If
End If
End If

fnGetPO = a

End Function

or

Public Function fnGetPO(w, x, y, x) As String
Dim a As String

If Not IsNull(w) Then
a = w
ElseIf Not IsNull(x) Then
a = x
ElseIf Not IsNull(y) Then
a = y
ElseIf Not IsNull(z) Then
a = z
Else
a = "None"
End If

fnGetPO = a

End Function


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


patti said:
Thanks for the speedy reply.

Where is the function looking for the value?
Is it looking at [ON Order PO Info].[m1 po], etc? Is that what becomes the
"strPO"?



Douglas J. Steele said:
The function accepts four values. If there's a value for the first
parameter, the function returns that value. If the first parameter has a
Null value, but there is a value for the second parameter, the function
returns that value. If thefirst and second parameters both have Null
values,
but there's a value for the third parameter, the function returns that
value. If the first, second and third parameters all have Null values,
but
there's a value for the fourt parameter, the function returns that value.
If
all of the first, second, third and fourth parameters have Null values,
the
function returns the string "None".

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Can someone explain what is happening with this modGeneral module? ? I
have
hopefully just pulled out the necessary info.

Report "on open" event:

Public Function fnPopulateTable_2()
Dim strSQL As String
......
strSQL = "SELECT...fnGetPO([ON Order PO Info].[m1 po],[ON Order PO
Info].[m2
PO],[ON Order PO Info].[m3 po],[ON Order PO Info].[m4 po]..


modGeneral:


Public Function fnGetPO(po1, po2, po3, po4) As String
Dim strPO As String

If Not IsNull(po1) Then
strPO = po1
Else
If Not IsNull(po2) Then
strPO = po2
Else
If Not IsNull(po3) Then
strPO = po3
Else
If Not IsNull(po4) Then
strPO = po4
Else
strPO = "None"
End If
End If

End If
End If

fnGetPO = strPO
End Function


What is the mod looking at for "IsNull"?

Thanks.

patti
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top