Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 33
  1. #16
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642

    Like I posted, if no arguments there shouldn't be anything after:
    Quote Originally Posted by pbaldy View Post
    FormHeading

    or

    FormHeading 123, "abc"
    The second one would be for a function that required numeric and text arguments.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  2. #17
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    That is what you said, but as you can see in my example there are also quotes. quotes around the function name and quotes around the arguments. It seems that those quotes and the quotes that you site in

    FormHeading 123, "abc"

    around the arguments could get confusing. That is why it the earlier post, I refered to this specific example. Quotes are not arguments, they are delimiters and how do I use them when I redefine the function call as just the function name and it arguments also in double quotes.


    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed


  3. #18
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Your code is calling a macro, mine is calling a function directly. That's why yours has "DoCmd.RunMacro" at the beginning.

    If the function has no arguments, which yours didn't as I recall, there would be nothing after the function name, when calling the function from VBA.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #19
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I added the subprogram Sub updateButtons() to the form frmPersonnel's VBA code. The zipped db with the correction is now attached.

    It seemed to lack a definition of updateButtons. So I added a definition.

    Now it crashes on the line

    Me.btnClose.Enabled = False

    The same program sfrmTelework1 does not crash and I am unsure why.

    It must be getting to a definition in its VBA code that it is not getting to on frmPersonnel both have Sub updateButtons() .

    I am unsure why.

    The definition must be on the listed VBA code for sfrmTelework1. That is the only place it can be.

    If it were in the common code then it would not crash in frmPersonnel.

    How to fix this bug?

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed
    Attached Files Attached Files

  5. #20
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Remember that "Me" refers to the object the code is in. There is no "btnClose" on frmPersonnel. If you still want it to refer to the button on the subform, you need to use the full reference. If you want it to refer to the button on the main form, you need to use its name (looks like Command163).
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #21
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I not sure that I follow you. Yes, I understand about 'Me" even if I fail to use it correctly. But beyond that. In another form's VBA code there is a Sub updateButtons() and it works fine. I do not see a btnClose
    program there, but updateButttons works fine. Why does it work there and not in frmPersonnel?

    I believe the Sub updateButtons programs are the same and neither has "btnClose".

    Respectfully,

    Lou Reed

  7. #22
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Quote Originally Posted by Lou_Reed View Post
    I do not see a btnClose program there, but updateButttons works fine.
    Not a btnClose program, a control (button) named btnClose. The code tries to enable/disable a button. That button has to exist. It does on one, does not on the other.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #23
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Okay, I lazily copied the Sub updateButtons() from the sfrmTelework1 to frmPersonnel. That obviously does not work. One size does does fit all.

    That was clumsy of me. However, there is more than just the missing control on the frmPersonnel. There is also a reference to tblTelework in the line DCount. That clearly does not work. Something must replace the tblTelework reference. Is this right?

    Thanks in advance.

    Respectfully,

    Lou Reed

  9. #24
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    i am not sure what the parent form is to sfrmTelework1 That is the way to see the update button.

    How do I ind the parent form to
    sfrmTelework1?

    R,

    Lou Reed

  10. #25
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Quote Originally Posted by Lou_Reed View Post
    There is also a reference to tblTelework in the line DCount. That clearly does not work. Something must replace the tblTelework reference. Is this right?
    No, that's fine. The table still exists, regardless of which form you refer to it from. It also refers to a control on the form, so that's okay too (because it's the form the code is in). I've seen it work the way you have it, but I always concatenate:

    If DCount("*", "tblTelework", "[PersonnelID] = " & [Forms]![frmPersonnel].[PersonnelID] & " AND [isActive] = true") = 0 Then
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #26
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    How do I change the Sub updateButtons in frmPersonnel so it compiles. Also, should do something about tbltelework1, remove it or change it? The table tbltelework1 is just not relevant to anything in
    frmPerspnnel. It is out of place.

    Also, give me way to find a parent form from a subform, that would make things easier.

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed

  12. #27
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Lou, I don't know what you're trying to accomplish. The simple answer to "How do I change the Sub updateButtons in frmPersonnel so it compiles" is to change it to refer to controls that exist on that form, or change the reference to refer to the control(s) on the original subform.

    Regarding "
    The table tbltelework1 is just not relevant to anything in frmPerspnnel." There is no table with that name. There is a form used as a subform. If it isn't relevant to frmPersonnel, delete that subform control. If appropriate, also delete the form of that name.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  13. #28
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Quote Originally Posted by pbaldy View Post
    Lou, I don't know what you're trying to accomplish. The simple answer to "How do I change the Sub updateButtons in frmPersonnel so it compiles" is to change it to refer to controls that exist on that form, or change the reference to refer to the control(s) on the original subform.

    Regarding "
    The table tbltelework1 is just not relevant to anything in frmPerspnnel." There is no table with that name. There is a form used as a subform. If it isn't relevant to frmPersonnel, delete that subform control. If appropriate, also delete the form of that name.
    Okay, substitute tblTelework for tbltelework1 . That was my mistake.


    Now , I
    would like to change the controls to match what is on that form. I just do not know what controls are on that form!

    The examples that I used had the controls on the subform and the way to see a subform is by opening its parent hence the question if I want to see a subform and its controls I must
    open its parent form. So if I have a subform how do I find its parent form?

    Also, as I said before should not
    tblTelework be removed or changed n the VBA code for frmPersonnel? I do not see it relevance.

    Any help appreciated. Thanks in advance.

    Respectfully,


    Lou Reed

  14. #29
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Quote Originally Posted by Lou_Reed View Post
    So something like

    DoCmd.RunMacro "FormHeading", , ""

    would be rewritten as:

    FormHeading ", ,""

    Any help appreciated. Thanks I advance.

    Respectfully,

    Lou Reed

    Please note that there are three sets of double quotes.
    I think there is something wrong here. The double quotes are not balanced.

    So it should be:

    FormHeading ", ,"

    Is this correct?

    Thanks in advance.

    R,

    Lou Reed

  15. #30
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    In looking for controls, I feel like you're going about it the wrong way. You have the code on frmPersonnel. What do you want it to do? What controls on that form do you want to enable? Decide that, find their names and adjust the code.

    Regarding calling the function, it doesn't have any arguments, so there shouldn't be anything after the function name. As you have it in your code:

    FormHeading
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Help with NPV Macro Code in VBA
    By BigNasty in forum Macros
    Replies: 6
    Last Post: 11-21-2016, 10:39 PM
  2. Setting Code to Simple Numeric Age
    By wes9659 in forum Forms
    Replies: 6
    Last Post: 08-14-2014, 01:22 PM
  3. Setting Report Height In Code
    By ccordner in forum Reports
    Replies: 1
    Last Post: 12-07-2012, 10:26 PM
  4. VBA code/Macro help please.
    By Davidyam in forum Access
    Replies: 1
    Last Post: 02-26-2012, 09:59 PM
  5. Replies: 10
    Last Post: 01-04-2012, 01:43 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