Getting the column name that appears to the user
Hello.
I'm using VB6 and MS-Access. The real name of a column is "TabDepts.CodDept" but appears to the user as "Dept. Code".
Is there any way to get the column name that appears to the user?
I can't get it with OpenSchema. Only real names. Maybe I'm doing something wrong.
Any help? Thanks.
Re: Getting the column name that appears to the user
Thread moved from the 'CodeBank VB6' forum (which is for you to post working code examples, not questions) to the 'Database Development' forum
Re: Getting the column name that appears to the user
My guess is it is an alias in a query or the program is changing it. I don't think there is a disconnect between the database and the coumn names used to reference it. In other words "TabDepts.CodDept" is the column name and it is forced to display "Dept. Code" somehow.
Re: Getting the column name that appears to the user
Quote:
Originally Posted by
TysonLPrice
My guess is it is an alias in a query or the program is changing it. I don't think there is a disconnect between the database and the coumn names used to reference it. In other words "TabDepts.CodDept" is the column name and it is forced to display "Dept. Code" somehow.
I need to do that since I need to automate some warning messages to the user and I don't want to show real/internal names. Since I have many columns/fields, if I can't get it I will need to create some kind of list of column names and their respective names shown to the user. Something like this:
"TabDepts.CodDept" = "Dept. Code"
"TabDepts.CodComp" = "Component Code"
etc.
Remember I need to do that in VB6/MS-Access.
Re: Getting the column name that appears to the user
I'm on MS SQL but I think you need to do the leg work yourself. I don't see how the database can know what aliases you are using in queries and VB code unless they were actually assigned on the DB (if possible).
I'd be interested to know if it can be done with a simple report.
Re: Getting the column name that appears to the user
Quote:
Originally Posted by
TysonLPrice
I'm on MS SQL but I think you need to do the leg work yourself. I don't see how the database can know what aliases you are using in queries and VB code unless they were actually assigned on the DB (if possible).
I'd be interested to know if it can be done with a simple report.
In fact, the names are assigned on DB and I need to get them in my app using VB code. It´s possible to get real/internal names but I don´t know how to get the names that appears to the user. That´s the problem.
If I create that list I have mentioned before and in the future someone (or myself) changes the DB, then I will need to remember to update that list. That´s why I´m trying to avoid creating that list.
Re: Getting the column name that appears to the user
Quote:
Originally Posted by
jalexm
In fact, the names are assigned on DB and I need to get them in my app using VB code. It´s possible to get real/internal names but I don´t know how to get the names that appears to the user. That´s the problem.
If I create that list I have mentioned before and in the future someone (or myself) changes the DB, then I will need to remember to update that list. That´s why I´m trying to avoid creating that list.
I don't know Access but you lost me here. Where does TabDepts.CodDept display as "Dept. Code"? What would you see if you ran this query against the DB?
Select TabDepts.CodDept from Mytable where TabDepts.CodDept = 'VBForums'
Would you see:
CodDept
VBForums
or
Dept. Code
VBForums
I guess what I'm thinking is selects are using aliases or what the user sees is manipulated in the program and you will need to find them there, not on the DB.
Otherwise...I'm all wet :blush:
Re: Getting the column name that appears to the user
Quote:
Originally Posted by
TysonLPrice
I don't know Access but you lost me here. Where does TabDepts.CodDept display as "Dept. Code"? What would you see if you ran this query against the DB?
Select TabDepts.CodDept from Mytable where TabDepts.CodDept = 'VBForums'
Would you see:
CodDept
VBForums
or
Dept. Code
VBForums
I guess what I'm thinking is selects are using aliases or what the user sees is manipulated in the program and you will need to find them there, not on the DB.
Otherwise...I'm all wet :blush:
Sorry for the delay.
In fact, my app uses a DB created in Access but everything is made by my app.
When an error occurs, Access send a message to my app and it shows something like "TabDepts.CodDept is not valid." (I can't remember exactly). I can trap the error and get its number and message.
This way I can avoid to show the original message to the user. Next step is to find "TabDepts.CodDept" string in original error message and replace it by "Dept. Code" and show the new message: "Dept. Code is not valid."
I can do all of these things, but I don't have a way to get the column names that appear to the user. I can get only internal/real names although both are defined in Access.
No problem if I have few fileds/columns. But there are many. That's the problem.
Re: Getting the column name that appears to the user
Sorry can't help then...I didn't know access stored the columns that way.