|
-
Jan 11th, 2000, 06:39 AM
#1
Thread Starter
New Member
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?
-
Jan 11th, 2000, 01:02 PM
#2
Guru
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
-
Jan 11th, 2000, 11:10 PM
#3
Frenzied Member
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).]
-
Jan 12th, 2000, 11:57 AM
#4
Guru
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|