Results 1 to 8 of 8
  1. #1
    Join Date
    May 2004
    Posts
    10

    Unanswered: tab controlled forms

    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

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    What is the code you used to reference the subform?

  3. #3
    Join Date
    May 2004
    Posts
    10

    Angry

    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
    Last edited by short; 05-24-04 at 12:58.

  4. #4
    Join Date
    Nov 2003
    Posts
    1,487
    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:

    Code:
    If IsLoaded("AddInfo") then
       Forms![AddInfo]![fieldstaff].Form![myControlNameOnSubForm] = whatever
    End if
    Where:

    Addinfo is the form that contains the Tab control which in turn also contains the fieldstaff SubForm.

    myControlNameOnSubForm is 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:


    Code:
    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
    	End If
     End If
    End Function

    Hope this helps...


  5. #5
    Join Date
    May 2004
    Posts
    10
    thank you, I will give this a try

  6. #6
    Join Date
    May 2004
    Posts
    10
    does this work with Access 97, I'm still getting errors

  7. #7
    Join Date
    Nov 2003
    Posts
    1,487
    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.

    What is the error?


  8. #8
    Join Date
    May 2004
    Posts
    1

    hmmm

    It could be because your control is called "Name". That is a reserved word in Access/VBA.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •