Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Jul 2003
    Location
    Cincinnati, Ohio
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Setting a value based on form called from (xp)

    Good morning. I have three forms: (frmservers, frmapplications, frmIssues, all are based on respective tables). frmissues is called from either of the other two by a linked open form button. It has the following fields: IssuesID, ServersID, ApplicationsID, Notes. I am trying to set the value for the serversid or applicationsid depending on whether the form was opened from the frmservers or frmapplications. Additionally, I'm would like to disable the visibility of the non-selected ID field on frmIssues. I have a beforeinsert event on the frmIssues form with the following code.
    ***
    Private Sub Form_BeforeInsert(Cancel As Integer)
    If IsLoaded("frmservers") Then
    Me.ServerID.Value = Forms!frmservers!ServerID
    ApplicationID.Visible = False
    Else
    If IsLoaded("frmapplications") Then
    Me.ApplicationID.Value = Forms!frmapplications!ApplicationID
    ServerID.Visible = False
    End If
    End Sub
    ***
    I am getting "compile error: sub or function not defined" on the first ISLOADED statement.
    I've read help but am still stuck. Any help would be most appreciated.
    Thanks. - scott

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Setting a value based on form called from (xp)

    IsLoaded is not a built-in function. In XP, it is a property of the AccessObject uh, object, but you can't use that directly because this property is also True if the object is open in design view. You can use the following function (from the Northwind database):

    Function IsFormLoaded(ByVal strFormName As String) As Integer
    Const conObjStateClosed = 0
    Const conDesignView = 0
    If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed Then
    If Forms(strFormName).CurrentView <> conDesignView Then
    IsFormLoaded = True
    End If
    End If
    End Function

    I recommend not naming this function IsLoaded to avoid confusion with the IsLoaded property. If you put this function in a general module, you can use it anywhere in your database. You will need to replace the occurrences of IsLoaded in your code with IsFormLoaded.

  3. #3
    2 Star Lounger
    Join Date
    Jul 2003
    Location
    Cincinnati, Ohio
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Setting a value based on form called from (xp)

    Thank you for your help and insight re: isloaded. I'm going to try your suggestion.
    -scott

Posting Permissions

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