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
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.
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
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).
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
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
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
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
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
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.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.
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
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
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