![]() |
Microsoft Query
I use Microsoft Query to connect and to bring in the information from a
database in a SQL server. I have no problem bring the info in. However, I have a problem creating a custom field. For example, I have Fields (Columns) A and B. I want to create Field C that combines the values from Fields A and B. In Access, I can create a Field C by writing this expression in a query: Field C: Field A & Field B I tried to write a similar expression, and it does not recognize it. Please help. Thanks. |
Microsoft Query
If your Query was originally:
SELECT a.first_name, a.surname FROM example.dbo.a then to create a third column combining both names (Full_Name), you would use: SELECT a.first_name, a.surname, a.first_name+' '+a.surname AS 'Full_Name' FROM example.dbo.a Hope this helps. Please Help wrote: I use Microsoft Query to connect and to bring in the information from a database in a SQL server. I have no problem bring the info in. However, I have a problem creating a custom field. For example, I have Fields (Columns) A and B. I want to create Field C that combines the values from Fields A and B. In Access, I can create a Field C by writing this expression in a query: Field C: Field A & Field B I tried to write a similar expression, and it does not recognize it. Please help. Thanks. |
Microsoft Query
JackeyC,
Thanks for your help. I tried your code, and I got this error message "Incorrect syntax near ']'. Statement[s] could not be prepared.". If I then change my code to [Field]![A]+"."+[Field]![b], I would receive this error message, SQL Query can't be represented graphically. Continue anyway? If I click OK on it, I would then receive this error message, Incorrect column expression: '[' Thanks again. "JakeyC" wrote: If your Query was originally: SELECT a.first_name, a.surname FROM example.dbo.a then to create a third column combining both names (Full_Name), you would use: SELECT a.first_name, a.surname, a.first_name+' '+a.surname AS 'Full_Name' FROM example.dbo.a Hope this helps. Please Help wrote: I use Microsoft Query to connect and to bring in the information from a database in a SQL server. I have no problem bring the info in. However, I have a problem creating a custom field. For example, I have Fields (Columns) A and B. I want to create Field C that combines the values from Fields A and B. In Access, I can create a Field C by writing this expression in a query: Field C: Field A & Field B I tried to write a similar expression, and it does not recognize it. Please help. Thanks. |
Microsoft Query
It would help me if you posted the exact query. I'm a bit confused as
to why you're using the [] and ! in it? Please Help wrote: JackeyC, Thanks for your help. I tried your code, and I got this error message "Incorrect syntax near ']'. Statement[s] could not be prepared.". If I then change my code to [Field]![A]+"."+[Field]![b], I would receive this error message, SQL Query can't be represented graphically. Continue anyway? If I click OK on it, I would then receive this error message, Incorrect column expression: '[' Thanks again. "JakeyC" wrote: If your Query was originally: SELECT a.first_name, a.surname FROM example.dbo.a then to create a third column combining both names (Full_Name), you would use: SELECT a.first_name, a.surname, a.first_name+' '+a.surname AS 'Full_Name' FROM example.dbo.a Hope this helps. Please Help wrote: I use Microsoft Query to connect and to bring in the information from a database in a SQL server. I have no problem bring the info in. However, I have a problem creating a custom field. For example, I have Fields (Columns) A and B. I want to create Field C that combines the values from Fields A and B. In Access, I can create a Field C by writing this expression in a query: Field C: Field A & Field B I tried to write a similar expression, and it does not recognize it. Please help. Thanks. |
Microsoft Query
Good morning JakeyC,
Thanks again for your help. I took a different approach by creating a query in Access and linking that query to the Excel via Microsoft Query. I think Microsoft Query has more limitations than Access on what you can do. Anyhow, I do have one more question. How do I protect my Microsoft Query from the users going in and messing things up? I have a protection on the workbook "Structure". However, if the user has an External Data toolbar, they can click on the Edit Query button to go into the query. Thanks again. "JakeyC" wrote: It would help me if you posted the exact query. I'm a bit confused as to why you're using the [] and ! in it? Please Help wrote: JackeyC, Thanks for your help. I tried your code, and I got this error message "Incorrect syntax near ']'. Statement[s] could not be prepared.". If I then change my code to [Field]![A]+"."+[Field]![b], I would receive this error message, SQL Query can't be represented graphically. Continue anyway? If I click OK on it, I would then receive this error message, Incorrect column expression: '[' Thanks again. "JakeyC" wrote: If your Query was originally: SELECT a.first_name, a.surname FROM example.dbo.a then to create a third column combining both names (Full_Name), you would use: SELECT a.first_name, a.surname, a.first_name+' '+a.surname AS 'Full_Name' FROM example.dbo.a Hope this helps. Please Help wrote: I use Microsoft Query to connect and to bring in the information from a database in a SQL server. I have no problem bring the info in. However, I have a problem creating a custom field. For example, I have Fields (Columns) A and B. I want to create Field C that combines the values from Fields A and B. In Access, I can create a Field C by writing this expression in a query: Field C: Field A & Field B I tried to write a similar expression, and it does not recognize it. Please help. Thanks. |
Microsoft Query
You can either password-protect the database you connect to, or protect
the sheet and lock the cell that contains the query. Please Help wrote: Good morning JakeyC, Thanks again for your help. I took a different approach by creating a query in Access and linking that query to the Excel via Microsoft Query. I think Microsoft Query has more limitations than Access on what you can do. Anyhow, I do have one more question. How do I protect my Microsoft Query from the users going in and messing things up? I have a protection on the workbook "Structure". However, if the user has an External Data toolbar, they can click on the Edit Query button to go into the query. Thanks again. "JakeyC" wrote: It would help me if you posted the exact query. I'm a bit confused as to why you're using the [] and ! in it? Please Help wrote: JackeyC, Thanks for your help. I tried your code, and I got this error message "Incorrect syntax near ']'. Statement[s] could not be prepared.". If I then change my code to [Field]![A]+"."+[Field]![b], I would receive this error message, SQL Query can't be represented graphically. Continue anyway? If I click OK on it, I would then receive this error message, Incorrect column expression: '[' Thanks again. "JakeyC" wrote: If your Query was originally: SELECT a.first_name, a.surname FROM example.dbo.a then to create a third column combining both names (Full_Name), you would use: SELECT a.first_name, a.surname, a.first_name+' '+a.surname AS 'Full_Name' FROM example.dbo.a Hope this helps. Please Help wrote: I use Microsoft Query to connect and to bring in the information from a database in a SQL server. I have no problem bring the info in. However, I have a problem creating a custom field. For example, I have Fields (Columns) A and B. I want to create Field C that combines the values from Fields A and B. In Access, I can create a Field C by writing this expression in a query: Field C: Field A & Field B I tried to write a similar expression, and it does not recognize it. Please help. Thanks. |
Microsoft Query
JakeyC,
Thanks again for your help. It works when I password-protect the Access database. You might have noticed. I posted the same message this morning titled "Protecting a Microsoft Query". Since I got my answer, please do not respond to it. Thanks. "JakeyC" wrote: You can either password-protect the database you connect to, or protect the sheet and lock the cell that contains the query. Please Help wrote: Good morning JakeyC, Thanks again for your help. I took a different approach by creating a query in Access and linking that query to the Excel via Microsoft Query. I think Microsoft Query has more limitations than Access on what you can do. Anyhow, I do have one more question. How do I protect my Microsoft Query from the users going in and messing things up? I have a protection on the workbook "Structure". However, if the user has an External Data toolbar, they can click on the Edit Query button to go into the query. Thanks again. "JakeyC" wrote: It would help me if you posted the exact query. I'm a bit confused as to why you're using the [] and ! in it? Please Help wrote: JackeyC, Thanks for your help. I tried your code, and I got this error message "Incorrect syntax near ']'. Statement[s] could not be prepared.". If I then change my code to [Field]![A]+"."+[Field]![b], I would receive this error message, SQL Query can't be represented graphically. Continue anyway? If I click OK on it, I would then receive this error message, Incorrect column expression: '[' Thanks again. "JakeyC" wrote: If your Query was originally: SELECT a.first_name, a.surname FROM example.dbo.a then to create a third column combining both names (Full_Name), you would use: SELECT a.first_name, a.surname, a.first_name+' '+a.surname AS 'Full_Name' FROM example.dbo.a Hope this helps. Please Help wrote: I use Microsoft Query to connect and to bring in the information from a database in a SQL server. I have no problem bring the info in. However, I have a problem creating a custom field. For example, I have Fields (Columns) A and B. I want to create Field C that combines the values from Fields A and B. In Access, I can create a Field C by writing this expression in a query: Field C: Field A & Field B I tried to write a similar expression, and it does not recognize it. Please help. Thanks. |
All times are GMT +1. The time now is 06:38 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com