Concatenating Fields in sql-string in vba 
Author Message
 Concatenating Fields in sql-string in vba

Hello everyone,

Could someone help if it is possible to concatenate fields
in a sql string written in a VBA procedure.

I have combobox which looks up different tables, one is
from company's and one is from customers. The recordsource
is decided when i click on a button. The one from
customers i would like to concatenate, but it doesn't work.
here's the example:

on cmdCustomerCompany_click()

cmbOrder.recordsource = "SELECT companyname from companys"

on cmbOrder_AfterUpdate()

cmbOrder.recordsource = "SELECT firstname, middlename,
lastname from customers"

What i want is to concatenate firstname and lastname like
this: Trim(Firstname & " " & middlename) & " " & lastname
as name



Sun, 28 Aug 2005 19:36:44 GMT  
 Concatenating Fields in sql-string in vba
You probably want a string that looks like:

"SELECT firstname & "" "" & middlename & "" "" & lastname as FullName from
customers"

Note: That the quotes have been doubled around the spaces to be inserted in the
string.  

In addition, while this will display James Paul Wodehouse that it will not do
much beyond that.

Quote:

> Hello everyone,

> Could someone help if it is possible to concatenate fields
> in a sql string written in a vba procedure.

> I have combobox which looks up different tables, one is
> from company's and one is from customers. The recordsource
> is decided when i click on a button. The one from
> customers i would like to concatenate, but it doesn't work.
> here's the example:

> on cmdCustomerCompany_click()

> cmbOrder.recordsource = "SELECT companyname from companys"

> on cmbOrder_AfterUpdate()

> cmbOrder.recordsource = "SELECT firstname, middlename,
> lastname from customers"

> What i want is to concatenate firstname and lastname like
> this: Trim(Firstname & " " & middlename) & " " & lastname
> as name



Sun, 28 Aug 2005 20:20:13 GMT  
 Concatenating Fields in sql-string in vba
thanks that works for me. How about if want to sort the
list in an alfabetical order?


Tue, 30 Aug 2005 06:53:55 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Custom fields: concatenating project & task strings

2. Sql, make string field a date field.

3. Having trouble accessing single field key with two concatenated fields

4. Concatenating a Text Field and a Number Field

5. Can't use a string variable as a Table Field name in VBA

6. Concatenate string with single and double quotes

7. Concatenate Text String

8. Concatenate Large Strings is awful slow

9. Quick way to concatenate strings ??

10. concatenate string and integer

11. How to Concatenate string with Constant?

12. Concatenating large strings

 

 
Powered by phpBB® Forum Software