Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Akchayan is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Aug 2022
    Posts
    102

    Form linked to a table

    Hello everyone,



    I have this table here:
    Click image for larger version. 

Name:	Screenshot 2022-10-17 142904.jpg 
Views:	29 
Size:	49.4 KB 
ID:	48914
    And I have a dropdown list in a form that accesses the table (The table is called tblContent). The drop-down list gets the data from the column "Designation". As you can see in the first picture, it has the columns named "Untertext" and "Untertext2".


    The form looks like this:
    Click image for larger version. 

Name:	Screenshot 2022-10-17 142247.png 
Views:	28 
Size:	8.5 KB 
ID:	48913
    As I just said, the drop-down list is marked with the number 1.
    And the "txtfield" should be filled with the "subtext" and "subtext2" after the update.
    How do I do this?

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,545
    Can you post a copy of the db
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    5,035
    Bring that data into the combo and just refer to the relevant columns when the combo is updated.
    At the moment you appear to be using the same source for both controls?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    Join Date
    Apr 2017
    Posts
    1,689
    What exactly you have and want to do?

    a) You have a form based on table tblContent, and you want to select a specific designation/Bezeichnung and to display matching Untertext and Untertext2 in separate text boxes? Then your design will be a single or continuous form with hidden text box linked with ID field (in case ID is autonumeric), and text boxes linked with Bezeichnubg, Untertext, and Untertext2 fields. Plus you have an unbound combo for record selection, with a query as record source (like "SELECT ID, Bezeichnung FROM tblContent ORDER BY 2"), with 2nd column visible. When any Bezeichnug is selected, the AfterUpdate event of combo activates matching record for form;

    b) You have some form based on another table/query, and in this table is a field, where an ID for Bezeichnung is stored. In form, you want a combo to select Bezeichnung. You link this combo to bezeichnung ID of form source table, and have the combo's record source of combo like above (i.e. based on tblContent), with 2nd column of query displayed. To display additional info about selected Bezeichnung, have unbound text box(es) in form, with formula(s) to return Untertext/Untertext2 from tblContent matching with selected Bezeichnung ID, and create an AfterUpdate event for combo to refresh those unbound text boxes.

  5. #5
    Akchayan is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Aug 2022
    Posts
    102
    Quote Originally Posted by ArviLaanemets View Post
    What exactly you have and want to do?

    a) You have a form based on table tblContent, and you want to select a specific designation/Bezeichnung and to display matching Untertext and Untertext2 in separate text boxes? Then your design will be a single or continuous form with hidden text box linked with ID field (in case ID is autonumeric), and text boxes linked with Bezeichnubg, Untertext, and Untertext2 fields. Plus you have an unbound combo for record selection, with a query as record source (like "SELECT ID, Bezeichnung FROM tblContent ORDER BY 2"), with 2nd column visible. When any Bezeichnug is selected, the AfterUpdate event of combo activates matching record for form;

    b) You have some form based on another table/query, and in this table is a field, where an ID for Bezeichnung is stored. In form, you want a combo to select Bezeichnung. You link this combo to bezeichnung ID of form source table, and have the combo's record source of combo like above (i.e. based on tblContent), with 2nd column of query displayed. To display additional info about selected Bezeichnung, have unbound text box(es) in form, with formula(s) to return Untertext/Untertext2 from tblContent matching with selected Bezeichnung ID, and create an AfterUpdate event for combo to refresh those unbound text boxes.
    The 2nd Point.

  6. #6
    Join Date
    Apr 2017
    Posts
    1,689
    What to do is explained there. NB! When calculating Untertext/Untertext2, refer to combo control, not to ID field in table. Changes to field value doesn't happen before the record is saved.

  7. #7
    Akchayan is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Aug 2022
    Posts
    102
    Quote Originally Posted by Bob Fitz View Post
    Can you post a copy of the db
    Test.zip
    That's a test DB.

  8. #8
    Akchayan is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Aug 2022
    Posts
    102
    Quote Originally Posted by ArviLaanemets View Post
    What to do is explained there. NB! When calculating Untertext/Untertext2, refer to combo control, not to ID field in table. Changes to field value doesn't happen before the record is saved.
    I don't really understand what you mean.

  9. #9
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,545
    Take a look at the attached db.

    I have added 2 hiddend columns to your combo box which are referenced in the Control Source property of the textboxes to get the data from them.
    Please note that the Column() property is zero based, so the first column is Column(0), the second is Column(1) etc.
    Post back if you have questions. Hope this helps.
    Attached Files Attached Files
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  10. #10
    Akchayan is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Aug 2022
    Posts
    102
    Quote Originally Posted by Bob Fitz View Post
    Take a look at the attached db.

    I have added 2 hiddend columns to your combo box which are referenced in the Control Source property of the textboxes to get the data from them.
    Please note that the Column() property is zero based, so the first column is Column(0), the second is Column(1) etc.
    Post back if you have questions. Hope this helps.
    Thank you very much you helped me alot, but i have one question:
    Click image for larger version. 

Name:	Screenshot 2022-10-17 210023.png 
Views:	26 
Size:	3.9 KB 
ID:	48917
    Is it possible that, for example in this case, after "-Sicherheitsbestimmung / Sicherheitskultur der Huser Gebäudetechnik AG" there is one line below the next one?

  11. #11
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,581
    Hi
    It might be that your structure is slightly wrong.

    If you select a "Designation" would you want to see only those "Captions" associated with the Designation selected?
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  12. #12
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    5,035
    Quote Originally Posted by Akchayan View Post
    Thank you very much you helped me alot, but i have one question:
    Click image for larger version. 

Name:	Screenshot 2022-10-17 210023.png 
Views:	26 
Size:	3.9 KB 
ID:	48917
    Is it possible that, for example in this case, after "-Sicherheitsbestimmung / Sicherheitskultur der Huser Gebäudetechnik AG" there is one line below the next one?
    Look to see how Bob combined them, then use vbCRLF in the concatenation. I will let you work out where it should go.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  13. #13
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,545
    Quote Originally Posted by Akchayan View Post
    Thank you very much you helped me alot, but i have one question:
    Click image for larger version. 

Name:	Screenshot 2022-10-17 210023.png 
Views:	26 
Size:	3.9 KB 
ID:	48917
    Is it possible that, for example in this case, after "-Sicherheitsbestimmung / Sicherheitskultur der Huser Gebäudetechnik AG" there is one line below the next one?
    I believe Gasman has sent you in the right direction with his advice in post #12 but please post back if you're still unable to get the desired result.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  14. #14
    Akchayan is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Aug 2022
    Posts
    102
    Quote Originally Posted by Bob Fitz View Post
    I believe Gasman has sent you in the right direction with his advice in post #12 but please post back if you're still unable to get the desired result.
    I have more or less achieved the result I wanted, but is there a way that this:
    Click image for larger version. 

Name:	Screenshot 2022-10-17 210023.png 
Views:	12 
Size:	3.9 KB 
ID:	48918
    is written directly into a report?


    I tried it that way but it didn't work:
    Click image for larger version. 

Name:	Screenshot 2022-10-19 083555.png 
Views:	12 
Size:	6.2 KB 
ID:	48919

  15. #15
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,545
    Try:
    =[Kombinationsfeld0].[Column](2) & """ & vbCrLf & """ & [Kombinationsfeld0].[Column](3)
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 12-17-2015, 07:01 AM
  2. Replies: 4
    Last Post: 03-02-2015, 07:54 PM
  3. Replies: 9
    Last Post: 10-24-2014, 11:34 AM
  4. Replies: 9
    Last Post: 10-20-2014, 04:00 PM
  5. Replies: 2
    Last Post: 04-15-2014, 10:03 PM

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