Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2006
    Posts
    111

    Unanswered: How do I close my form?

    I have a form with an Add button and right after pressing add I want to insert a record to my db (no problem there), close the form and return to, plus run a requery on, the previous form which should show the new record I just added in its list.

    First problem: I can't close the form. I thought this would be something as simple as docmd.close but I think that was actually closing the previous form.

    To refresh the data on the previous form, is that just a requery and is this syntax correct: Forms![History Filter General].Requery and are there rules where I can call that instruction from?


    Thx

  2. #2
    Join Date
    May 2005
    Posts
    1,191
    Quote Originally Posted by M Mock
    First problem: I can't close the form. I thought this would be something as simple as docmd.close but I think that was actually closing the previous form.
    It should be that easy, unless something else has the focus. To specificy, just do like
    Code:
    DoCmd.Close acForm, "FrmName", acSaveNo
    Quote Originally Posted by M Mock
    To refresh the data on the previous form, is that just a requery and is this syntax correct: Forms![History Filter General].Requery and are there rules where I can call that instruction from?
    Does what you have work? Cause if it does, then it is correct. Else, what I commonly do is something like (untested)
    Code:
    docmd.hourglass true
    docmd.echo false
    
    docmd.close acForm, "FrmName", acSaveNo
    docmd.OpenForm "FrmName"
    
    docmd.hourglass false
    docmd.echo true
    But this may not necessarily work in your situation. Care to elaborate on your situation?
    Me.Geek = True

  3. #3
    Join Date
    Jul 2006
    Posts
    111
    I'm all set on the requery. I thought it wasn't refreshing (requerying), but it was, I just didn't have the right data in one of my table's columns so the new record wasn't showing up.

    I will try what you suggested to close the form. Thanks.

  4. #4
    Join Date
    Jul 2006
    Posts
    111
    Working beautifully!

    Thank you for taking the time to answer my very basic questions. I'm doing a project for a customer and it takes me a while to get used to Access's way of doing things.

  5. #5
    Join Date
    Sep 2006
    Posts
    265
    Tip - closing the form should be the last command. Do whatever is needed first that is reliant of that particular form i.e. open a report or query etc and then close the form using the form name. If you want to reuse the information from a dialogue box open it in a hidden state and open it again in the usual way.

Posting Permissions

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