Results 1 to 4 of 4

Thread: Undefined function in expression

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Location
    Wellington, New Zealand
    Posts
    9

    Post

    I have been programming for several years in Access and have recently begun to program in VB.

    In Access I can include a global function within an SQL statement to manipulate the selected input data to output a new (usually reformatted) field. For example, depending on the value of a [Member Type] field I can format the [Member Name] as [Title Description + First Names + Surname] or [Rank Description + First Names + Surname] where [First Names] and [Surname] are fields in the [Member] table and the Title and Rank Descriptions are held in separate tables.

    When I try to do the same thing in VB I get the error - Undefined function 'AAA' in expression!

    Is there any way in VB I can code an SQL statement to manipulate the selected input to produce a new formatted field?

  2. #2
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    Here is an example that uses the NWIND MDB file and concatenates 3 fields into one with SQL:

    Code:
        Dim cn As Connection
        Dim rs As Recordset
        
    
        Set cn = New Connection
    
        cn.Open "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=Nwind.mdb"
        
        Set rs = cn.Execute("Select CustomerID + ' ' + CompanyName + ' ' + ContactName as Name from Customers")
        
        MsgBox rs.Fields("Name").Value

  3. #3
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105

    Post

    As a matter of style, I use "&" when dealing with string concatinations, in place of "+". Both work _but_ the usage of "+" can, sometimes, have undesired effects (and this should not detract from what Tom has posted, which is correct)

    [This message has been edited by JHausmann (edited 01-12-2000).]

  4. #4
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    Good point.

    Yes, use '&' instead of '+' so you don't accidentally add your numeric fields together when you wanted to concatenate them.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width