I am trying to set the value of a control on a subform that is placed on a tab sheet of a tab controlled form, and get the error "The object you referenced in the Visual Basic Procedure as an OLE object isn't and OLE object".
I am trying to set the value of a control called Name, by using an expression that combines to other fields. I have done this on other forms, but they were not subforms or on a tab controlled form.
any help would be appreciated. thanks
I believe that is where my problems is, every combination of things I try get the same result. I am using a macro in access, and its the "item" that I can not seem to get correct. The last one I tried was [subform controlname].form![controlname].
my set up is
Main form = AddInfo
Tab control page = fieldstaff which houses the fieldstaff subform
hope that helps
If you are in a form and you want to reference a subform located in another open form (doesn't matter if it's in a tab control) then you can reference it this way:
If IsLoaded("AddInfo") then
Forms![AddInfo]![fieldstaff].Form![myControlNameOnSubForm] = whatever
Addinfo is the form that contains the Tab control which in turn also contains the fieldstaff SubForm.
myControlNameOnSubFormis the name of the control within the fieldstaff SubForm you would like to reference and change the value of.
whatever is the new value.
IsLoaded is a function used to determine whether or not the form we want to reference is in fact open. The form must be open otherwise a error is generated. If you do not have the IsLoaded Function then here it is. Just place it into a database code module:
Public Function IsLoaded(ByVal strFormName As String) As Integer
' Returns True if the specified form is open in Form view or Datasheet view.
Const conObjStateClosed = 0
Const conDesignView = 0
If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed Then
If Forms(strFormName).CurrentView <> conDesignView Then
IsLoaded = True
This works in Access97 as well. I have tested this in Access97 and it works. You need to remember though...you must set focus onto the specific record in the subform where you would like to change the value. You can also do this via VBA code.