Results 1 to 9 of 9

Thread: Getting the column name that appears to the user

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2012
    Posts
    35

    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.

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    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

  3. #3
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,969

    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.

  4. #4

    Thread Starter
    Member
    Join Date
    Feb 2012
    Posts
    35

    Re: Getting the column name that appears to the user

    Quote Originally Posted by TysonLPrice View Post
    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.

  5. #5
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,969

    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.

  6. #6

    Thread Starter
    Member
    Join Date
    Feb 2012
    Posts
    35

    Re: Getting the column name that appears to the user

    Quote Originally Posted by TysonLPrice View Post
    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.
    Last edited by jalexm; Feb 29th, 2012 at 12:17 PM.

  7. #7
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,969

    Re: Getting the column name that appears to the user

    Quote Originally Posted by jalexm View Post
    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

  8. #8

    Thread Starter
    Member
    Join Date
    Feb 2012
    Posts
    35

    Re: Getting the column name that appears to the user

    Quote Originally Posted by TysonLPrice View Post
    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
    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.

  9. #9
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,969

    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.

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