Function Trouble

  • Thread starter Thread starter Chris Nebinger
  • Start date Start date
C

Chris Nebinger

You need to set up the Function as:

Public Function Height(strFrom as String) as String


Then Call it by:

Select tblPltMvs.From, tblPltMvs.To, height
(tblPltMvs.From) AS Expr1


One thing. Strings can not handle null values. If you
have any records without the From field filled in, you
will get an error. Change that by:

Public Function Height(strFrom as Variant) as Variant



Chris Nebinger
-----Original Message-----
Good morning,
I have been getting an error: "Ambigous name. in query
expression height()" when I try to run an Access query
with SQL code:
SELECT tblPltMvs.From, tblPltMvs.To, height() AS Expr1
FROM tblPltMvs;

My VBA function is below. It is supposed to return a
value (height) that gives the height of the pallet from
the floor based on [from] slot number. Slots are
designated as such:
Aisle (1-2 letters)
Bay (numbers)
Slot (1 letter or 2 numbers) - letters denote RESERVE
slots and numbers denote PICK/SELECTION slots.
"DOOR" is at the center of the dock

Public Function Height()
Dim FLevel As String
If Right([from], 1) <> "E" And Right([from], 1) <> "F"
And Right([from] said:
If [from] = "DOOR" Then FLevel = "0"
If Right([from], 2) = "10" Then FLevel = "A"
If Right([from], 2) = "20" Then FLevel = "C"
Else: FLevel = Right([from], 1)
End If
Select Case FLevel
Case "A"
Height = 0
Case "C"
Height = 52.5
Case "1", "2", "3", "4", "5"
Height = 0
Case "E"
Height = 103
Case "F"
Height = 155
Case "G"
Height = 206.5
Case "T"
Height = 258
End Select
End Function


Can someone please tell me what I am doing wrong? I need
to pass the 'from' slot number into the function, but even
when I put it as height(from as string), it's not working.
 
Chris
I changed the query and the function as suggested (variant), and I still get the same error message. Since FROM is a SQL reserved word, I even changed that, and no improvement

Do you have any other ideas

Thank you
Dere

----- Chris Nebinger wrote: ----

You need to set up the Function as

Public Function Height(strFrom as String) as Strin


Then Call it by

Select tblPltMvs.From, tblPltMvs.To, heigh
(tblPltMvs.From) AS Expr


One thing. Strings can not handle null values. If you
have any records without the From field filled in, you
will get an error. Change that by

Public Function Height(strFrom as Variant) as Varian



Chris Nebinge
-----Original Message----
Good morning
I have been getting an error: "Ambigous name. in query
expression height()" when I try to run an Access query
with SQL codevalue (height) that gives the height of the pallet from
the floor based on [from] slot number. Slots are
designated as such
Bay (numbers
Slot (1 letter or 2 numbers) - letters denote RESERVE
slots and numbers denote PICK/SELECTION slots
"DOOR" is at the center of the doc
Public Function Height(
Dim FLevel As Strin
If Right([from], 1) <> "E" And Right([from], 1) <> "F"
And Right([from] said:
If [from] = "DOOR" Then FLevel = "0
If Right([from], 2) = "10" Then FLevel = "A
If Right([from], 2) = "20" Then FLevel = "C
Else: FLevel = Right([from], 1
End I
Select Case FLeve
Case "A
Height =
Case "C
Height = 52.
Case "1", "2", "3", "4", "5
Height =
Case "E
Height = 10
Case "F
Height = 15
Case "G
Height = 206.
Case "T
Height = 25
End Selec
End Functio
to pass the 'from' slot number into the function, but even
when I put it as height(from as string), it's not working
 
I'm glad I totally did not help......

Seriously, glad you got it working.


Chris Nebinger

-----Original Message-----
Duh! I forgot that I already had a function named
HEIGHT. Thus, the ambiguous name... Thanks anyway, Chris!
Derek

----- Derek Wittman wrote: -----

Chris,
I changed the query and the function as suggested
(variant), and I still get the same error message. Since
FROM is a SQL reserved word, I even changed that, and no
improvement.
Do you have any other ideas?

Thank you!
Derek

----- Chris Nebinger wrote: -----

You need to set up the Function as:

Public Function Height(strFrom as String) as String


Then Call it by:

Select tblPltMvs.From, tblPltMvs.To, height
(tblPltMvs.From) AS Expr1


One thing. Strings can not handle null values. If you
have any records without the From field filled in, you
will get an error. Change that by:

Public Function Height(strFrom as Variant) as Variant



Chris Nebinger
-----Original Message-----
Good morning,
I have been getting an error: "Ambigous name.
in query
expression height()" when I try to run an Access query
with SQL code:
AS Expr1
FROM tblPltMvs;
return a
value (height) that gives the height of the pallet from
the floor based on [from] slot number. Slots are
designated as such:
Bay (numbers)
Slot (1 letter or 2 numbers) - letters denote
RESERVE
slots and numbers denote PICK/SELECTION slots.
"DOOR" is at the center of the dock
Public Function Height()
Dim FLevel As String
If Right([from], 1) <> "E" And Right([from],
1) said:
And Right([from], 1) <> "G" And Right([from],
1) said:
Then
If [from] = "DOOR" Then FLevel = "0"
If Right([from], 2) = "10" Then FLevel = "A"
If Right([from], 2) = "20" Then FLevel = "C"
Else: FLevel = Right([from], 1)
End If
Select Case FLevel
Case "A"
Height = 0
Case "C"
Height = 52.5
Case "1", "2", "3", "4", "5"
Height = 0
Case "E"
Height = 103
Case "F"
Height = 155
Case "G"
Height = 206.5
Case "T"
Height = 258
End Select
End Function
Can someone please tell me what I am doing
wrong? I need
to pass the 'from' slot number into the function, but even
when I put it as height(from as string), it's not working.
.
 
Acutally, you did. My old HEIGHT function was wrong, and your suggesting Variant over STRING made a difference in the long run. (besides, anyone else who looks up the same thing may find your suggestion helpful as well)

Now, though, I'm working on incorporating a little human common sense into a distance calculation. I'm mapping warehouse aisles in Access by way of linear distances. But that's another topic..

Thanks again, Chris
Dere

----- Chris Nebinger wrote: ----

I'm glad I totally did not help.....

Seriously, glad you got it working


Chris Nebinge

-----Original Message----
Duh! I forgot that I already had a function named
HEIGHT. Thus, the ambiguous name... Thanks anyway, Chris
I changed the query and the function as suggested
(variant), and I still get the same error message. Since
FROM is a SQL reserved word, I even changed that, and no
improvement
Do you have any other ideas
Thank you Dere
----- Chris Nebinger wrote: ----
You need to set up the Function as
Public Function Height(strFrom as String) as Strin
Select tblPltMvs.From, tblPltMvs.To, heigh (tblPltMvs.From) AS Expr
values. If you
have any records without the From field filled in, you
will get an error. Change that by
Public Function Height(strFrom as Variant) as Varian
Good morning
I have been getting an error: "Ambigous name.
in query
expression height()" when I try to run an Access query
with SQL code
AS Expr
FROM tblPltMvs
return a
value (height) that gives the height of the pallet from
the floor based on [from] slot number. Slots are
designated as such
Bay (numbers
Slot (1 letter or 2 numbers) - letters denote
RESERVE
slots and numbers denote PICK/SELECTION slots
"DOOR" is at the center of the doc
Public Function Height(
Dim FLevel As Strin
If Right([from], 1) <> "E" And Right([from],
1) said:
And Right([from], 1) <> "G" And Right([from],
1) said:
The
If [from] = "DOOR" Then FLevel = "0
If Right([from], 2) = "10" Then FLevel = "A
If Right([from], 2) = "20" Then FLevel = "C
Else: FLevel = Right([from], 1
End I
Select Case FLeve
Case "A
Height =
Case "C
Height = 52.
Case "1", "2", "3", "4", "5
Height =
Case "E
Height = 10
Case "F
Height = 15
Case "G
Height = 206.
Case "T
Height = 25
End Selec
End Functio
Can someone please tell me what I am doing
wrong? I need
to pass the 'from' slot number into the function, but even
when I put it as height(from as string), it's not working
 
Back
Top