Page 2 of 2 FirstFirst 12
Results 16 to 29 of 29
  1. #16
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664



    John_G

    VIP Windows 7 32bit Access 2010 32bit


    Join DateOct 2011LocationOttawa, ON (area)Posts2,249

    So I have to open Forms!sfrmTelework1 ?


    No, you have to change the references to refer to the proper form, in this case the one the code is in.

    All occurances of Forms!sfrmTelework1 should be changed to Forms!frmNewTelework in the code module for frmNewTelework. (Me! will also work)

    It looks to me as if that code was ported from somewhere else (the formsfrmTelework1 ?). There is nothing wrong with doing that - it can save a lot of time - but when you do, you have to look through the code to make sure the references (forms, controls, other subs, etc) will still be valid, and to make sure the code logic still applies in the new location.


    You will have to explain the logic in adding an N/A to my current selections of current and situational. What is this line saying. it is obviously a conditional, but please explain.


    It's not adding "N/A" to anything, it is testing for it. the line If Me!TelWorkType <> "N/A" then says "If the contents of the form control 'TelWorkType' are not equal to 'N/A', then do...whatever is in the If-Endif block"

    TelWorkType happens to be a combo box in this case, but it could be a textbox.
    The string "N/A" has no particular meaning to Access - the code can check for any string you choose.

    It is this bit that has me thinking that the code was ported from somewhere else, where "N/A" could actually be a value that was in a text box or combo box.




    This is an early quote (#5) in this thread and I take it, it is no longer supported by you. In a subsequent quote (#7) you said '


    So now (Ahem, mea culpa) - forget what I wrote above, and I'll start again.


    So now I must change any reference to


    In the code, all references to Forms!sfrmTelework1 will fail. Because sfrmTelework1 is a subform, it cannot be referenced as part of the Forms! collection. To refer to a control on the subform, you need: Forms!frmPersonnel!sfrmTeleWork1.form!txtTeleworkType. In that reference, sfrmTeleWork1 is NOT the name of the subform - it is the name of the form control that contains the subform. In your case here, the two names just happen to be the same, so be aware of which one you have to use.


    So now I have the following code sets:

    Code:
    
    
    Code:
    Forms!sfrmPropertyPass1.Requery
    Forms!sfrmPropertyPass.Requery
    Forms!sfrmPropertyPass1.updateButtons
    [/code]


    and

    Code:
        Forms!sfrmTelework1.Requery
        Forms!sfrmTelework.Requery
        Forms!sfrmTelework1.updateButtons
    So how do I change these in light of your latest post in this thread?

    Any help appreciated. Thanks in advance.

    respectfully,

    Lou Reed

  2. #17
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Copied from Post #7 AND post #15:

    In the code, all references to Forms!sfrmTelework1 will fail. Because sfrmTelework1 is a subform, it cannot be referenced as part of the Forms! collection. To refer to a control on the subform, you need: Forms!frmPersonnel!sfrmTeleWork1.form!txtTeleworkType. In that reference, sfrmTeleWork1 is NOT the name of the subform - it is the name of the form control that contains the subform. In your case here, the two names just happen to be the same, so be aware of which one you have to use.


    It's the same idea with those three lines, except that you have a different subform container control - sfrmPropertyPass1


    Lou, this time I am not going to TELL you the change - I want you to THINK about what the required change should be (hint - it's in red above). Read the text in italics above, and see if you can apply it to those three lines.

    Reply Reply With Quote

  3. #18
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716

  4. #19
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    No, I inherited ts db. I would never have done it like this if I created the db.

    Respectfully,

    Lou Reed

  5. #20
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Okay, I appreciate the help and to show my gratitude I will make the sun disappear on the east cost of the U.S. in the next half hour. It is now 2:26 pm east standard time.

    Watch and be amazed.

    Respectfully,

    Lou Reed

  6. #21
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Okay, eclipse day over let us start again seriously. In the code section that I listed:

    Code:
     Forms!sfrmTelework1.Requery
     Forms!sfrmTelework.Requery
     Forms!sfrmTelework1.updateButtons



    Code:
    Forms!sfrmPropertyPass1.Requery
    Forms!sfrmPropertyPass.Requery
    Forms!sfrmPropertyPass1.updateButtons
    I must assume something is correct in order to correct the other parts. The part that I assume is correct
    is the subform that is trying to be accessed. If that assumption does not hold the whole statement is wrong.
    If it does hold then the first part of the statement is wrong and only the first part of the statement is wrong.

    Form there I believe that I can put in the correct code. But I must at least assume the subform trying to be accessed
    is correct.

    Is this valid?

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed

  7. #22
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    No, those lines won't work. As I have said, repeatedly, they do not reference the subform correctly.

    Check the link in Orange's post #18, and this (for the fourth time):

    In the code, all references to Forms!sfrmTelework1 will fail. Because sfrmTelework1 is a subform, it cannot be referenced as part of the Forms! collection. To refer to a control on the subform, you need: Forms!frmPersonnel!sfrmTeleWork1.form!txtTeleworkType. In that reference, sfrmTeleWork1 is NOT the name of the subform - it is the name of the form control that contains the subform. In your case here, the two names just happen to be the same, so be aware of which one you have to use.


  8. #23
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Further to John's advice and the thread generally, here is a link to info re form, subform and subform control.

    To Access, a subform isn't a form at all, but a control, so you must reference it as such.
    http://www.techrepublic.com/blog/mic...ubform-107106/

  9. #24
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Quote Originally Posted by John_G View Post
    No, those lines won't work. As I have said, repeatedly, they do not reference the subform correctly.

    Check the link in Orange's post #18, and this (for the fourth time):

    In the code, all references to Forms!sfrmTelework1 will fail. Because sfrmTelework1 is a subform, it cannot be referenced as part of the Forms! collection. To refer to a control on the subform, you need: Forms!frmPersonnel!sfrmTeleWork1.form!txtTeleworkType. In that reference, sfrmTeleWork1 is NOT the name of the subform - it is the name of the form control that contains the subform. In your case here, the two names just happen to be the same, so be aware of which one you have to use.

    I know those lines as they are written will not work. No argument there. But to correct them, I must make some assumptions or else throw the whole set of three lines out.

    So I assumed the rightmost subform part was correct.

    From there I then would consider was is wrong with the code after Forms!.

    Form!***********sfrmTelework1.Requery

    In order to make the correction, there some facts that I must assume. The **** represents something that is either wrong as is stands now or something has been left out.

    That is the purpose of the post #21.

    I assume Forms! and sfrmTelework1.Requery are correct, but what is between them is not (as I said it is either left out or if it is in, it is incorrect.

    In Post #18 the reference is quite useful. But in order to use it you must know what form or subform that you are on. Is this true?

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed

  10. #25
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Lou,

    In Post #18 the reference is quite useful. But in order to use it you must know what form or subform that you are on. Is this true?
    YES!

    Watch these videos -- from Datapig.
    http://www.datapigtechnologies.com/f...subforms1.html
    http://www.datapigtechnologies.com/f.../subform2.html

  11. #26
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    The syntax is:

    Forms!MainFormName!ControlName.form.requery

    where MainFormName is the name of the main form and
    ControlName is the name of the control, on the main form, that contains the subform. It is NOT the name of the subform.


  12. #27
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Quote Originally Posted by John_G View Post
    No, those lines won't work. As I have said, repeatedly, they do not reference the subform correctly.

    Check the link in Orange's post #18, and this (for the fourth time):

    In the code, all references to Forms!sfrmTelework1 will fail. Because sfrmTelework1 is a subform, it cannot be referenced as part of the Forms! collection. To refer to a control on the subform, you need: Forms!frmPersonnel!sfrmTeleWork1.form!txtTeleworkType. In that reference, sfrmTeleWork1 is NOT the name of the subform - it is the name of the form control that contains the subform. In your case here, the two names just happen to be the same, so be aware of which one you have to use.


    I would like to recreate this error , I commented out the line "On Error Resume Next".

    The VBA code compiled with no problem, so I assume it must be a run-time error.

    I am just trying to learn by recreating the error.

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed

  13. #28
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Forms!sfrmPropertyPass1.Requery
    Forms!sfrmPropertyPass.Requery
    forma.sfrmPropertyPass1.UpdateButtons

    Forms!frmPersonnel!sfrmPropertyPass1.form!requery

    Forms!frmPersonnel!sfrmPropertyPass1.form!updateBu ttons


    Now I am not sure how to write the second one. The subform sfrmPropertyPass is called by sfrmPropertyPass1.

    How does that fit in?

    I do not know.


    The other lines for telework are written the same way; bit include Telework instead of PropertyPass.

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed














    I am not sure hot write he second one correctly.
    Forms!sfrmPropertyPass1.updateButtons Forms!frmPeronnel!sfrmPropertyPass.form.UpdateButt ons.

  14. #29
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Forms!frmPersonnel!sfrmPropertyPass1.form!requery
    Almost. !requery has to be .Requery (with a period), because Requery is a method, not a control.

    Forms!frmPersonnel!sfrmPropertyPass1.form!updateBu ttons
    Almost. Change !updateButtons to .updateButtons (with a period). UpdateButtons is a Sub, with different versions occurring in three forms/subforms (frmPersonnel, sfrmTelework1, and sfrmPropertyPass1). Each version updates properties of buttons of the form/subform it is in.

    Now I am not sure how to write the second one. The subform sfrmPropertyPass is called by sfrmPropertyPass1.
    Forms!sfrmPropertyPass.Requery
    is called by isn't really the correct term there - is referred to by is a better term.

    The subform sfrmPropertyPass is a subform on frmPersonnel, just as sfrmPropertyPass1 is, so you refer to it in a similar manner:

    Forms!frmPersonnel!sfrmPropertyPass.form.Requery

    It's only my opinion, but it is a terrible naming convention for those subform container controls on frmPersonnel. Trying to keep track of which is which, i.e. with or without the "1" at the end of the name is very confusing, and will be very error-prone when writing VBA. Try to avoid that sort of naming when designing your own forms.

    Just as a guide for you when you are fixing this up, there are at least 25 occurrances of "Forms!sfrm..." (in many forms) in your database - they are all erroneous references to subforms and will need changing.

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

Similar Threads

  1. A most unusual query
    By Lou_Reed in forum Access
    Replies: 3
    Last Post: 04-27-2017, 03:13 PM
  2. An unusual(?) parent-child form
    By bnorton in forum Access
    Replies: 10
    Last Post: 08-19-2014, 04:55 PM
  3. Replies: 3
    Last Post: 04-10-2013, 01:20 PM
  4. Unusual string
    By Yap in forum Access
    Replies: 6
    Last Post: 12-13-2012, 08:35 PM
  5. Percent textbox unusual behaviour
    By Deutz in forum Forms
    Replies: 4
    Last Post: 06-05-2011, 06:46 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