Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Kendrick, Idaho, USA
    Posts
    277
    Thanks
    1
    Thanked 0 Times in 0 Posts

    fields captions (2000)

    I want to let the user change a table field caption from a dialog box. To write the VBA code, I need to access the caption property of the field. How do I do that?

    Thanks

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: fields captions (2000)

    Are you talking about the caption for fields in the tables themselves or the labels they might have on a form or report? You don't actually need to change the caption of the field in order to allow the user to do some customization. If you're using ADO, it is going to be an exercise in frustration because when you can get at the caption property it's read-only. You can use DAO to change the caption of a field, but enlarge on what you're trying to accomplish so the answers will suit the question.
    Charlotte

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Kendrick, Idaho, USA
    Posts
    277
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: fields captions (2000)

    No, I requested what I wanted - access to the captions for a table. It's a relatively simple system, and the user may want to see the raw data in the table. Thus I want to caption the table fields so that if he does so, the columns of the table are appropriately named. I am giving the user 8 user-named fields, originally Field1, Field2, etc. plan a setup screen from which he could caption the fields. There is a form in which he enters his data, but modifying the labels for the form fields has not been the challenge that captioning the table fields has.

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: fields captions (2000)

    Show us the code you're trying to use, and someone will be able to help.
    Charlotte

  5. #5
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: fields captions (2000)

    Here a function to change the caption of a field.
    This code suppose:
    -You have set a reference to Microsoft DAO 3.6 Object Library
    -The table exist
    -The field exist
    -The field already have a caption<pre>Sub ChangeCaption(TableName As String, _
    FieldName As String, _
    NewCaption As String)
    Dim db As DAO.Database
    Dim tdf As DAO.TableDef
    Dim fld As DAO.Field
    Dim x As Integer
    Set db = CurrentDb
    Set tdf = db.TableDefs(TableName)
    Set fld = tdf.Fields(FieldName)
    fld.Properties("Caption") = NewCaption
    Set fld = Nothing
    Set tdf = Nothing
    Set db = Nothing
    End Sub</pre>

    Just save the code in a module, save the module with another name then ChangeCaption and call the routine with :
    Call ChangeCaption("MyTable",MyField","This is a new caption")
    Francois

Posting Permissions

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