Results 1 to 6 of 6
  1. #1
    redekopp is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2015
    Location
    Saskatoon
    Posts
    108

    if statement about forms

    Hello, if possible could someone tell me the if statement for opening/closing forms

    in my case I want it to be that if "frmcustomers" is already open do nothing.
    if "frmcustomers" is not already open then open "frmcustomers"

    thank you kindly.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Search on IsLoaded, which can be used to tell you if the form is open.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    redekopp is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2015
    Location
    Saskatoon
    Posts
    108
    Quote Originally Posted by pbaldy View Post
    Search on IsLoaded, which can be used to tell you if the form is open.
    sorry, im not sure what that means.

    This is for a button onclick event

    I need part of it to be like

    if "frmcustomers" is open then do nothing
    if "frmcustomers" is not open then open "frmcustomers"

    the reason is im using the form where the button is located from two different entry points, one where the "frmcustomers" will be already open and one where it will be closed.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    The code would look like:

    Code:
    If Not <IsLoaded code here> Then
      DoCmd.OpenForm "frmcustomers"
    End If
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    redekopp is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2015
    Location
    Saskatoon
    Posts
    108
    Quote Originally Posted by pbaldy View Post
    The code would look like:

    Code:
    If Not <IsLoaded code here> Then
      DoCmd.OpenForm "frmcustomers"
    End If
    tried
    Code:
    If Not CurrentProject.AllForms(frmcustomers).IsLoaded Then
        DoCmd.OpenForm "frmcustomers"
        Else
        End If
    it tells me frmcustomers "variable not defined"
    ive never used isloaded before not sure what im doing to be honest.


    EDIT: quotes around frmcustomers. got it thank you Pbaldy.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    The form name needs to be in quotes.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 11
    Last Post: 04-29-2015, 01:38 PM
  2. Replies: 2
    Last Post: 11-05-2014, 09:16 AM
  3. if statement in sql statement, query builder
    By 54.69.6d.20 in forum Access
    Replies: 4
    Last Post: 09-11-2012, 07:38 AM
  4. Replies: 7
    Last Post: 08-17-2011, 01:49 PM
  5. Replies: 1
    Last Post: 01-04-2011, 05:04 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