why Object Required with example

  • Thread starter Thread starter Mark R
  • Start date Start date
M

Mark R

Why am I getting error: OBJECT REQUIRED

I've narrowed it down to this code:

If Conferencesubformname.Form.Tag = "comm_red" Then
Conferencesubformname.Form.Backcolor = vbred
end if

============================

If Conferencesubformname!Form.Tag = "comm_red" Then
Conferencesubformname!Form.Backcolor = vbred
end if


BOTH SETS OF CODE CAUSE THE ERROR.
I have "comm_red" typed into the .Tag property of
the visible sub form named CONFERENCE

What is going on here?
 
1. I don't think there is a "BackColor" Property for a
Form Object (unless you use A2K3 which I haven't used a
lot).

2. Are you running the codes in the context of the Main
Form?

If you run the code in some other context, you need to
reference the Subform via its parent, i.e. the Main Form.
Something like:

Forms!MainForm!SubformControl.Form ...

Even in the context of the Main Form, I always use the
keyword "Me" rather than using the implicit reference.

HTH
Van T. Dinh
MVP (Access)
 
The correct syntax is your first one:
If Conferencesubformname.Form.Tag = "comm_red" Then
Conferencesubformname.Form.Backcolor = vbred
end if

However, do you have a control named the above? Remember, the sub-form name
is complete different then the name of the sub-form control on your form.
(they do not have to be the same name..and often are not).

You could also try:

If me.Conferencesbuformanme.Form.Tag

Try using the me., as you will get inteli-sense as to what the name of the
sub-form CONTROL you used here...

The above assume the code is running in the main form, and the
conferencessubforname is the name of the control.
 
Back
Top