Results 1 to 9 of 9
  1. #1
    shani908 is offline Novice
    Windows 11 Access 2019
    Join Date
    Feb 2023
    Posts
    24

    textbox to show description of focused field.


    Hello

    Please advise how to set a textbox to description of a field? and update it as the focus move from one field to another ?

    Thanks
    Attached Thumbnails Attached Thumbnails description-focus.png  

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,913
    Possibly code in each control's GotFocus event that sets value of Description textbox.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,418
    Are you talking about the field description in the table design?

    if so the code in the got focus event would be something like

    Txtdesc=tabledefs(“mytable”).fields(thiscontrol.co ntrolsource).description

    you haven’t provided any names so substitute with your names

  4. #4
    shani908 is offline Novice
    Windows 11 Access 2019
    Join Date
    Feb 2023
    Posts
    24
    Thank you for replying . I tried but I am a beginner with Access and was unable to get it running.
    Properties of table is attached.
    Properties of form is attached.

    I used BuildEvent to make some changes but its giving error. Please advise.

    Thanks


    Quote Originally Posted by CJ_London View Post
    Are you talking about the field description in the table design?

    if so the code in the got focus event would be something like

    Txtdesc=tabledefs(“mytable”).fields(thiscontrol.co ntrolsource).description

    you haven’t provided any names so substitute with your names
    Attached Thumbnails Attached Thumbnails error.png   table properties.png   form properties.png  

  5. #5
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,418
    I missed currentdb - and you don't have the rest quite right

    text39=currentdb.tabledefs(“mytable”).fields(
    thiscontrol.controlsource).description

    the code needs to go into each of the other controls got focus event, not text39

    thiscontrol is the name of the control that the code is in

    for future reference, when posting code, please copy/paste it and use the code tags to preserve formatting (highlight the pasted code and click the # button)

    and for your table/field design it is a bad idea to have spaces and non alpha numeric characters in their names (e.g. Last Name, Zip/Postcode). Leaving them in can cause some weird errors - even if you surround with square brackets. Can virtually guarantee if you don't fix this, every time you post a question you will be told again.

    Also recommend you get into the habit of giving controls meaningful names. Typically a textbox wouldhave a txt prefix, combo, cbo, list lst etc. eg txtFldDesc instrext of Text39

  6. #6
    shani908 is offline Novice
    Windows 11 Access 2019
    Join Date
    Feb 2023
    Posts
    24
    Thanks noted ..

    I am still getting error, please advise .

    attached error2.png and vbacode.png



    Quote Originally Posted by CJ_London View Post
    I missed currentdb - and you don't have the rest quite right

    text39=currentdb.tabledefs(“mytable”).fields(
    thiscontrol.controlsource).description

    the code needs to go into each of the other controls got focus event, not text39

    thiscontrol is the name of the control that the code is in

    for future reference, when posting code, please copy/paste it and use the code tags to preserve formatting (highlight the pasted code and click the # button)

    and for your table/field design it is a bad idea to have spaces and non alpha numeric characters in their names (e.g. Last Name, Zip/Postcode). Leaving them in can cause some weird errors - even if you surround with square brackets. Can virtually guarantee if you don't fix this, every time you post a question you will be told again.

    Also recommend you get into the habit of giving controls meaningful names. Typically a textbox wouldhave a txt prefix, combo, cbo, list lst etc. eg txtFldDesc instrext of Text39
    Attached Thumbnails Attached Thumbnails error2.png   vba_code.png  

  7. #7
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,798
    Your table name is not "myTable" perhaps??
    EDIT - nor is your control name "thiscontrol"?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,913
    As CJ already instructed, change the generic "mytable" and "thiscontrol" to your actual object names.

    You will often see generic aliases in sample code because we don't know your object names.
    Last edited by June7; 02-01-2023 at 08:37 PM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    shani908 is offline Novice
    Windows 11 Access 2019
    Join Date
    Feb 2023
    Posts
    24

    Red face

    Quote Originally Posted by June7 View Post
    As CJ already instructed, change the generic "mytable" and "thiscontrol" to your actual object names.

    You will often see generic aliases is sample code because we don't know your object names.
    Thanks . Noted . It worked

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 17
    Last Post: 10-18-2022, 02:11 AM
  2. Replies: 4
    Last Post: 04-30-2019, 10:40 AM
  3. Replies: 4
    Last Post: 04-03-2014, 08:03 AM
  4. i want to show description when i write the code
    By Mina Garas in forum Access
    Replies: 3
    Last Post: 02-23-2012, 11:00 AM
  5. Replies: 2
    Last Post: 09-26-2009, 07:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums