Access SQL function gives error

P

pwu

Hi,
I am using Microsoft Access 2003.

I have table s1:
syd
mel
adl
per
bne
drw
s1 has only one field “server”

I have table s2:
syd
mel
s1 has only one field “server”

I run this query:
SELECT s1.server, spellboolean(s2.server) AS [Exists?]
FROM s1 LEFT JOIN s2 ON s1.server = s2.server;

The spellboolean function is as follows:
Function spellboolean(b As String) As String
spellboolean = " "
On Error GoTo spell_err
If IsNull(b) Then
spellboolean = " "
Else
spellboolean = "*"
End If
spell_err:
Exit Function
End Function

I get the following results:
server Exists?
syd *
mel *
adl #Error
per #Error
bne #Error
drw #Error

Can someone tell me why I get the “#Error” in the second column? How
can I fix this?

I have also tried testing:
if b=””
with the same results.

Thanks for any help.
 
H

hans.updyke

I run this query:
SELECT s1.server, spellboolean(s2.server) AS [Exists?]
FROM s1 LEFT JOIN s2 ON s1.server = s2.server;

The spellboolean function is as follows:
Function spellboolean(b As String) As String
  spellboolean = " "
  On Error GoTo spell_err
  If IsNull(b) Then
    spellboolean = " "
  Else
    spellboolean = "*"
  End If
spell_err:
  Exit Function
End Function

I get the following results:
server  Exists?
syd     *
mel     *
adl     #Error
per     #Error
bne     #Error
drw     #Error

Can someone tell me why I get the “#Error” in the second column? How
can I fix this?

Change the type of your function's parameter to variant:

Function spellboolean(b As Variant) As String

Hans
 

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

Similar Threads


Top