Results 1 to 4 of 4
  1. #1
    FRSPA is offline Novice
    Windows XP Access 2007
    Join Date
    May 2011
    Posts
    7

    Code info on Open form


    Is there any form property that we can use to inform VBA code that a form is open? If not, what could be a solution?

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Can you give us a bit more detail abiut what you are trying to do.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    JeroenMioch's Avatar
    JeroenMioch is offline Competent Performer
    Windows Vista Access 2003
    Join Date
    May 2012
    Location
    Den Haag, Netherlands
    Posts
    368
    Im not sure if i understand you correct and what the purpose might be, But there is a way to see if your form is opened on another location for example.
    I would make a very basic table, for example tblOpenForm and then make a field called FormOpened.
    Now, I would make a SQL statement that puts a value of 1 into that field when the form is opened.
    Then, i would make a SQL statement that puts a value of 0 into that field when the form is closed.
    Now you could make a field called fldFormOpened on your form that Dlookup's that value.

    Code:
    Private sub form_current()
    If dlookup ("tblOpenForm", "FormOpened") = "0" then
    me.fldFormOpened.value = "The form is closed"
    else
    me.fldOpened.value = "the form is open" 
    end sub
    I may have the syntaxis a little off, but this is how i would do it.
    Maybe theres a simpler way though, not sure.

  4. #4
    FRSPA is offline Novice
    Windows XP Access 2007
    Join Date
    May 2011
    Posts
    7
    I've look to a related topic and it provided me an interesting function. See the code below.

    Thanks.

    Code:
    Public Function funIsLoadedForm(ByVal strFormName As String) As Boolean
    ' Returns True if the specified form is open in Form view or Datasheet view.
    On Error GoTo Error_funIsLoadedForm
    Const conObjStateClosed = 0
    Const conDesignView = 0
    If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed Then
    If Forms(strFormName).CurrentView <> conDesignView Then
    funIsLoadedForm = True
    End If
    End If

    Exit_funIsLoadedForm:
    Exit Function

    Error_funIsLoadedForm:
    MsgBox "Error in funIsLoadedForm: " & Err.Number & " - " & Err.Description
    Resume Exit_funIsLoadedForm

    End Function

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 05-03-2012, 02:25 PM
  2. VB Code to open a form?
    By HeadGasket in forum Access
    Replies: 1
    Last Post: 01-24-2012, 08:26 PM
  3. Replies: 5
    Last Post: 10-28-2011, 02:42 PM
  4. Form Code refresh on open
    By mseeker22 in forum Forms
    Replies: 2
    Last Post: 07-08-2011, 12:35 AM
  5. Replies: 2
    Last Post: 02-26-2010, 08:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums