Results 1 to 15 of 15
  1. #1
    Perfac's Avatar
    Perfac is offline Expert
    Windows 7 64bit Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618

    Visibility


    Me and Ruben(my son and partner) may not claim to be that serious rookies anymore, but here is a rookie question. On many forms we used visibility "false" or "True" successful and we like it. We have not yet successfully got one field on a subform to rotate between visibility "false" and "true" pending on the selection. We are now trying to learn for there is great use for it. We have a control on the main form T001. If that control =38 then T025 which is a control on the only subform we want the control to display on the form, and when not 38 the visibility must be false. We typed the VBA correct as it works in many other places, but we don't get visibility to be false. We also tested to set visibility to No and then make visibility True when 38 is the value in T001. Not working. Is there something we miss?

  2. #2
    Perfac's Avatar
    Perfac is offline Expert
    Windows 7 64bit Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    On the image the first field TrnTpe_ID04 is named T001 and CmdEnt_ID65 is namedT025. We want T025 to be visible on the form and the first CmbEnt_ID20 named T020 to be False on visibility when T001 is 38. Else T020 must be visible "True", and T025 visibility False.
    Click image for larger version. 

Name:	Visibility.png 
Views:	39 
Size:	83.6 KB 
ID:	35219

  3. #3
    Join Date
    Apr 2017
    Posts
    1,681
    Into OnCurrent event of Main form, and into AfterUpdate event of control T001 add a row (on fly, I didn't test it)
    Code:
    Forms("YourMainForm").Controls("YourSubformName").Form.Controls("T025").Visible = (Me.T001 = 38)

  4. #4
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Can I just say from an observational point of view, that your control naming is awful, and your field naming is "unusual" ?

    In six months time, this
    Code:
    ... .Form.Controls("T025").Visible = (Me.T001 = 38)

    will probably mean nothing to you.

    Surely the control for CmdEnt_ID65 would be better named cmbCmdEnt , and the control for TrnTpe_ID04 would be cmbTrnType? This indicates they are a combo and what field they are used for.

    Adding an _ID## or a number to the end of all your field names makes for a massive amount of extra typing, and in my mind makes them much less readable?
    I'm genuinely intrigued - what purpose does it serve?




    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  5. #5
    Perfac's Avatar
    Perfac is offline Expert
    Windows 7 64bit Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    Quote Originally Posted by ArviLaanemets View Post
    Into OnCurrent event of Main form, and into AfterUpdate event of control T001 add a row (on fly, I didn't test it)
    Code:
    Forms("YourMainForm").Controls("YourSubformName").Form.Controls("T025").Visible = (Me.T001 = 38)
    This VBA did not succeed in setting the visibility to no, when I looked into the subfrom the visibility was still set to "Yes", I have used similar code to set the visibility on a report and was successful... Don't know if this code has to be executed while the object isn't open
    Click image for larger version. 

Name:	Visibility.PNG 
Views:	35 
Size:	8.6 KB 
ID:	35220

  6. #6
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    Your subform is a datasheet? Go into design view, select any or even all controls that are datasheet fields and set their visibility to NO in the property sheet and reopen the form. The fields will still be there. Why? I'm not sure, but suspect it has to be that in a datasheet or continuous form, each record includes a copy of the control, so which one of those many copies would you not want to see? That would be why we are afforded the option to hide an entire column.

    Agree with the sentiment re: naming. Also, when you post, try to be more specific. "We have a form" or "We have a control" doesn't provide much information on which to base an answer. Better to say "we have a textbox on a continuous subform" for example.
    Last edited by Micron; 08-23-2018 at 07:47 AM. Reason: clarification
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    Perfac's Avatar
    Perfac is offline Expert
    Windows 7 64bit Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    Minty for your interest. On our payments form (that is any payment we make to any 3rd party) there is a selection in Transaction Type that states Account Payment. You may say that we keep a double set of books. The main ledger with as few as possible accounts to serve the balance sheet and the sub ledger with many accounts to give the detail. I.e. the main ledger have an account for Debtors to return one total for debtors, whilst in the Sub ledger each Debtor on its own. The challenge here is that some of our customers draw debit orders or pay salaries in batches. i.e. if they pay 10 employees salaries at once. There salary summary interlink with their bank. The 10 employees payment displays one total on the bankstatement, but the subform here show the 10 employees names. We must succeed that these 10 payments still ends up against Salary and Wage control, but display the employee names.

    If we under normal instance choose Salary and wage control that is the name that will display in the ledger. I hope you understand our system and process is on payday that a salary summary is created with up to 5 deductions per employee and the total net amount gets credited to Salary and Wage for lets say 10 employees. Then the 10 payments can be done one by one or like in this case as a batch. When it is a batch this field T025 displays the name of each employee as 10 debits in the Salary and Wage Control account.
    I am 55 and a better accountant(qualified) than programmer. But I am happy with the accounting process. We would like T025 to display and T020 not when T001 = 38. Not coming right yet. But Ruben is testing and will reply. Any advice to improve our decision is welcome.
    Thanks. Hans.

  8. #8
    Perfac's Avatar
    Perfac is offline Expert
    Windows 7 64bit Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    Minty and Micron. I don't have a life, and worked 17 hours a day since December 7 days a week, tell me about someone that has done more hours since 1st Jan on the planet. Our system is very close to where we want it, and we are proud of it. There is a chance that I will not shoot myself because you are so harsh on my naming convention. Through time we really welcome advice and took a lot of advice. Our more than 2000 fields each have a different name. We think that to be clever, even though some experts don't agree. We name all of our text fields starting T001, T002 etc on each separate form, and after 4 years I feel it works smoothly. Thanks I respect your experience and look forward to more opinions.

  9. #9
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    I understand that you have an accounting process, and that you understand that. (And I probably wouldn't )
    My point was about the way you are naming your controls and fields, not what they display.

    Quote : We would like T025 to display and T020 not when T001 = 38.

    This would make much more sense to everyone probably including you, if it read;

    We would like cmb
    CmdEnt to display and txtCmbEnt not display when cmbTransType = 38

    Like I said if you come back to visit this in 6 weeks time your first code will mean nothing to you.
    The second version would steer you much more quickly towards solving an issue as the names describe the controls and their field values

    Edit: Our posts crossed in the ether - If it works for you then that is most important and all well and good. I just feel sorry for someone external if they ever have to unravel it.



    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  10. #10
    Perfac's Avatar
    Perfac is offline Expert
    Windows 7 64bit Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    Smile. On Tony Robbins graphs you give us -2, I give us +7 on naming, but we learn. I am sure you are informed well enough on what we need. Not working just yet. Still testing.

  11. #11
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    This VBA did not succeed in setting the visibility to no
    not sure if the original question has been answered, but datasheets use a completely different set of properties around display - font, width, height, visibility etc. in the case of visibility rather than setting the control visible property to false you either use the columnhidden property (set to true) or set the columnwidth to equal 0. Datasheet properties are only available via VBA, they do not appear in the properties window.

  12. #12
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    Quote Originally Posted by Ajax View Post
    not sure if the original question has been answered...
    I thought as much in post 6 but the replies seem focused on everything else. Not even a confirmation or the form type (as far as I can see when using a phone to comment with).
    Last edited by Micron; 08-23-2018 at 01:14 PM. Reason: spelin and gramur
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  13. #13
    Perfac's Avatar
    Perfac is offline Expert
    Windows 7 64bit Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    Quote Originally Posted by Ajax View Post
    not sure if the original question has been answered, but datasheets use a completely different set of properties around display - font, width, height, visibility etc. in the case of visibility rather than setting the control visible property to false you either use the columnhidden property (set to true) or set the columnwidth to equal 0. Datasheet properties are only available via VBA, they do not appear in the properties window.
    Using the following code worked for a datasheet subform as well as setting it to true, to show the column again.

    Forms("f02PmtGenerate").Controls("f02PmtGenerateSu b").Form.Controls("T025").ColumnHidden = False

    Thanks for all the help
    Ruben

  14. #14
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    assuming your code is on the main form and relates to the subform, all you need is

    me.f02PmtGenerateSub.Form.T025.ColumnHidden = False

  15. #15
    Perfac's Avatar
    Perfac is offline Expert
    Windows 7 64bit Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    We are really happy about this one.

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

Similar Threads

  1. Label Visibility
    By joecamel9166 in forum Reports
    Replies: 3
    Last Post: 05-03-2016, 05:24 PM
  2. Macro using IF to set visibility in report
    By kyle87 in forum Macros
    Replies: 8
    Last Post: 07-23-2013, 01:24 PM
  3. Field Visibility
    By cbrsix in forum Programming
    Replies: 3
    Last Post: 06-27-2012, 03:52 PM
  4. subform visibility
    By nichmeg in forum Forms
    Replies: 9
    Last Post: 11-04-2011, 12:22 PM
  5. Visibility of other controls
    By jlclark4 in forum Forms
    Replies: 7
    Last Post: 12-15-2010, 12:34 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