This object doesn't contain the Automation object xxx

bgstrom32

New member
Local time
Today, 15:58
Joined
Aug 7, 2019
Messages
4
Greetings. I have a small issue that I'm sure will be a simple fix. I have a form with two radio buttons (by $ and by %). If the user selects "by $", then the % text boxes are grayed out, and vice versa for "by %". The code works as intended as I step through it. However, once I assign the code to a macro, I get the error "This object doesn't contain the Automation object Select_Invoice_Amount_Type". I tried to assign it to various events: on load, on click, after update...all get the same message. I then just assigned it to a command button, thinking the automation piece might be resolved...still same error. I'm sure I'm just overlooking something. Any help is appreciated.


Module:
Function Select_Invoice_Amount_Type()

With Forms.frm_Add_Invoice_Test

If .grp_Select_Type = 1 Then

.txt_dollar_1.Enabled = True
.txt_percent_1.Enabled = False

Else

.txt_dollar_1.Enabled = False
.txt_percent_1.Enabled = True

End If

End With

End Function
Macro
Function mcr_Option_Select()
On Error GoTo mcr_Option_Select_Err

Call Select_Invoice_Amount_Type


mcr_Option_Select_Exit:
Exit Function

mcr_Option_Select_Err:
MsgBox Error$
Resume mcr_Option_Select_Exit

End Function
 
Last edited:
Hi. Welcome to the forum! How about trying to use a bang instead of a dot? For example:
Code:
With Forms!frm_Add_Invoice_Test
Hope it helps...
 
use a bang(!) instead of a dot.

With [Forms]!Frm_Add_Invoice_Test
If !grp_Select_Type = 1 Then

!txt_dollar_1.Enabled = True
!txt_percent_1.Enabled = False

you use dot if it is an original member/method of the form.
anything you add to it (textbox, combos, radios) use bang.
 
Appreciate the quick response. I tried with the "!", but same result. The code itself works fine, because stepping through I get the desired result. It's some sort of breakdown between the macro and the form, it seems.

Updated code:

Function Select_Invoice_Amount_Type()

With [Forms]!frm_Add_Invoice_Test

If !grp_Select_Type = 1 Then

!txt_dollar_1.Enabled = True
!txt_percent_1.Enabled = False

Else

!txt_dollar_1.Enabled = False
!txt_percent_1.Enabled = True

End If

End With

End Function
 
Hi. When you get the error message, which line gets highlighted if you go to debug mode?
 
It doesn't bring up the debug option. I get the first popup that states "The object doesn't...." then click OK. Then it just brings up the "Stop All Macros" box. The code itself works fine, so I wouldn't imagine it would bring up the debug box.
 
It doesn't bring up the debug option. I get the first popup that states "The object doesn't...." then click OK. Then it just brings up the "Stop All Macros" box. The code itself works fine, so I wouldn't imagine it would bring up the debug box.
Hi. Can you post a screenshot of the "Stop All Macros" message box? Thanks.
 
I literally just deleted the macro and recreated...and bam...working. Beats me! Thanks to everyone for your help.
 
I literally just deleted the macro and recreated...and bam...working. Beats me! Thanks to everyone for your help.
Hi. Glad to hear you got it sorted out. Good luck with your project.
 

Users who are viewing this thread

Back
Top Bottom