RE: Function Trouble

From: Derek Wittman (anonymous_at_discussions.microsoft.com)
Date: 05/04/04


Date: Tue, 4 May 2004 11:26:08 -0700

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!
Derek
     
     ----- Chris Nebinger wrote: -----
     
     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:
>>>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], 1) <> "G" And Right([from],
     1) <> "T"
> 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.
>>>Thank you in advance!
>>Derek
>>.
>>>.
>



Relevant Pages

  • Re: Code to delete/unlink Linked tables
    ... Public intLinkODBCTables As Variant, intLinkDB2Tables As Variant ... Public strLinkBackendDB As String, strLinkDSNname As String, strLinkLibName ... ' MsgBox "This database is in MDE format...I will delete/recreate ODBC ... Public Sub fncLinkDB2Table() ...
    (microsoft.public.access.modulesdaovba)
  • Re: OPENFILENAME A P I. User cancels ?
    ... The variable FName will be a Boolean False if no file was selected or a String containing the fully qualified file name if the user selectes a file. ... Const ahtOFN_OVERWRITEPROMPT = &H2 ... Function GetOpenFile(Optional varDirectory As Variant, ... Dim strFilter As String ...
    (microsoft.public.excel.programming)
  • RE: multi-select file dialog
    ... strCustomFilter As String ... Global Const ahtOFN_OVERWRITEPROMPT = &H2 ... Dim strFilter As String ... Function GetOpenFile(Optional varDirectory As Variant, ...
    (microsoft.public.access.modulesdaovba)
  • Re: Replace space in text file
    ... In four of the above cases you have specified which type of variable you want VB to create (Integer, Long, String or whatever). ... in the case of vChars you have not specified the required variable type and VB will therefore create it as a Variant. ... For example, if vChars was an Integer then VB would read two bytes from the file, and if it was a Long it would read four bytes, and if it was a standard variable length String which currently contained nine characters then it would read nine characters from the file and if it was a String that currently contained just one character then it would read one character from the file. ...
    (microsoft.public.vb.general.discussion)
  • RE: multi-select file dialog
    ... strCustomFilter As String ... Global Const ahtOFN_OVERWRITEPROMPT = &H2 ... Dim strFilter As String ... Function GetOpenFile(Optional varDirectory As Variant, ...
    (microsoft.public.access.modulesdaovba)