Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    Jan 2001
    Location
    Bloomington, Indiana, USA
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Access field caption

    I'd like to use an Access field caption in an ASP page instead of the field name. Here's the code I'm using:

    <table border = "1" width="75%">
    <% For i = 1 to rsProject.Fields.Count - 1 %>
    <tr>
    <td width="20%"><%= rsProject(i).Name %>: </td>
    <td width="55%"><input type="text" name="<%= rsProject(i).Name %>" value="<%= rsProject(i).Value %>"></td>
    </tr>
    <% Next %>
    </table>

    Replacing the line <%= rsProject(i).Name %> with <%= rsProject(i).Caption %> doesn't work. Any guidance is greatly appreciated!

    Thanks,
    Kathy

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access field caption

    Hi Kathy,

    As you well know, you're using the ADO objects to connect to the Access database. Caption is a property that belongs to Access, not the ADO objects. Therefore reading Access's Caption property for a database field is not possible through the current version of ADO.

    Sorry <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>

    As an alternative, you could create a table with 2 colums: field_name and field_caption. Then pull the captions from the second table and the values from the original. Just be sure to make the order of the records in the second table to match the order of the fields you're using in the first table.

    Hope this helps

    Mark

  3. #3
    Star Lounger
    Join Date
    Jan 2001
    Location
    Bloomington, Indiana, USA
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access field caption

    I was hoping there was a way to get to the Access property -- it certainly explains why I couldn't find a reference for it in my ASP material...

    Thanks for the work around idea!

    Kathy

  4. #4
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access field caption

    Kathy,

    I was just struck by a thought... <img src=/S/brickwall.gif border=0 alt=brickwall width=25 height=15>

    Another, much easier alternative would be to create a query in Access with your desired captions as the fieldnames in the query. Your Field Name row in Access would read:

    My Field Name: [myfield]

    The SQL will say something like: SELECT myfield AS [My Field Name] FROM...

    This makes much more sense than creating a second table...sorry for the confusion.

  5. #5
    Star Lounger
    Join Date
    Jan 2001
    Location
    Bloomington, Indiana, USA
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access field caption

    No apologies! I'm glad you replied so quickly -- it stopped me from a futile search. Your new suggestion does sound easier. I greatly appreciate your help!!

    Thanks again,
    Kathy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •