help with DoCmd.Close

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • chanchito_cojones

    help with DoCmd.Close

    hi there,

    I am needing some help with a database I am putting together. The database
    works off of a main Form, which then has buttons on it that will open up
    other forms. The problem I am having is that if I am updating any
    information on the current record, and then open one of the other forms, the
    new form will not show the updated information. I realize that a simple
    macro solves this problem by basically closing the first form, opening the
    new form, and then on exiting the new form opening the first one again. The
    problem is, that with one of the sub forms that I need to open requires some
    vb script with it. Here is the script:

    Private Sub INDIVIDUALSLIP_ Click()
    On Error GoTo Err_INDIVIDUALS LIP_Click
    Dim stDocName As String
    Dim stLinkCriteria As String
    stDocName = "frmIndividualS lip"
    DoCmd.OpenForm stDocName, , , stLinkCriteria, , , SlipID.Value
    Exit_INDIVIDUAL SLIP_Click:
    Exit Sub

    Err_INDIVIDUALS LIP_Click:
    MsgBox Err.Description
    Resume Exit_INDIVIDUAL SLIP_Click
    End Sub


    Now, I have tried playing around with the DoCmd.Close but I just cannot seem
    to get it to work. It always ends up telling me that I am refering to
    something that doesn't exist or is already closed. So the help that I am
    seeking is basically being able to have the script not only do what it is
    currently doing, but also close the form so that the changes show when the
    new forms opens up. However, I think I just had one of those "eureka"
    moments. I think I see what my problem is...hehe...The main form has
    specific ID values attached to each record, and when the "frmIndividualS lip"
    is being called to open up, it is grabbing the ID value from the main form
    (which is still open) so that it will retrieve the record that is being
    looked at in the main form. Which is what I need it to do. So, now that I
    realize the obstacle that I am faced with, is there any way around it? Am I
    able to have the record that has been updated in the main form, still
    populate itself in the new form that is being called to open, and still
    contain the updated values?

    I also realize that this problem can be solved by just going forward one
    record, and then coming back to the record that was updated, and then
    calling the new form to open it, thus showing the new values. And this is
    what I have been doing, the only problem is that I know once I ask people to
    use this database they may forget from time to time to do the whole "forward
    then back".

    I really appreciate any help that can be offered.

    Thank You


  • PC Datasheet

    #2
    Re: help with DoCmd.Close

    If you don't leave the current form, it doesn't get saved. Eventually it gets
    saved when you close the form or return to the form and go to another record. In
    your code to open the other record, do a:
    DoCmd.RunComman d acSaveRecord
    before opening the other form.

    --
    PC Datasheet
    Your Resource For Help With Access, Excel And Word Applications
    resource@pcdata sheet.com



    "chanchito_cojo nes" <cheeseortuna@h otmail.com> wrote in message
    news:CEWSc.1668 031$Ar.475511@t wister01.bloor. is.net.cable.ro gers.com...[color=blue]
    > hi there,
    >
    > I am needing some help with a database I am putting together. The database
    > works off of a main Form, which then has buttons on it that will open up
    > other forms. The problem I am having is that if I am updating any
    > information on the current record, and then open one of the other forms, the
    > new form will not show the updated information. I realize that a simple
    > macro solves this problem by basically closing the first form, opening the
    > new form, and then on exiting the new form opening the first one again. The
    > problem is, that with one of the sub forms that I need to open requires some
    > vb script with it. Here is the script:
    >
    > Private Sub INDIVIDUALSLIP_ Click()
    > On Error GoTo Err_INDIVIDUALS LIP_Click
    > Dim stDocName As String
    > Dim stLinkCriteria As String
    > stDocName = "frmIndividualS lip"
    > DoCmd.OpenForm stDocName, , , stLinkCriteria, , , SlipID.Value
    > Exit_INDIVIDUAL SLIP_Click:
    > Exit Sub
    >
    > Err_INDIVIDUALS LIP_Click:
    > MsgBox Err.Description
    > Resume Exit_INDIVIDUAL SLIP_Click
    > End Sub
    >
    >
    > Now, I have tried playing around with the DoCmd.Close but I just cannot seem
    > to get it to work. It always ends up telling me that I am refering to
    > something that doesn't exist or is already closed. So the help that I am
    > seeking is basically being able to have the script not only do what it is
    > currently doing, but also close the form so that the changes show when the
    > new forms opens up. However, I think I just had one of those "eureka"
    > moments. I think I see what my problem is...hehe...The main form has
    > specific ID values attached to each record, and when the "frmIndividualS lip"
    > is being called to open up, it is grabbing the ID value from the main form
    > (which is still open) so that it will retrieve the record that is being
    > looked at in the main form. Which is what I need it to do. So, now that I
    > realize the obstacle that I am faced with, is there any way around it? Am I
    > able to have the record that has been updated in the main form, still
    > populate itself in the new form that is being called to open, and still
    > contain the updated values?
    >
    > I also realize that this problem can be solved by just going forward one
    > record, and then coming back to the record that was updated, and then
    > calling the new form to open it, thus showing the new values. And this is
    > what I have been doing, the only problem is that I know once I ask people to
    > use this database they may forget from time to time to do the whole "forward
    > then back".
    >
    > I really appreciate any help that can be offered.
    >
    > Thank You
    >
    >[/color]


    Comment

    • chanchito_cojones

      #3
      Re: help with DoCmd.Close

      You are a godsend!!! Thank you so much.

      cheers


      "PC Datasheet" <nospam@nospam. spam> wrote in message
      news:doXSc.1494 7$nx2.3953@news read2.news.atl. earthlink.net.. .[color=blue]
      > If you don't leave the current form, it doesn't get saved. Eventually it[/color]
      gets[color=blue]
      > saved when you close the form or return to the form and go to another[/color]
      record. In[color=blue]
      > your code to open the other record, do a:
      > DoCmd.RunComman d acSaveRecord
      > before opening the other form.
      >
      > --
      > PC Datasheet
      > Your Resource For Help With Access, Excel And Word Applications
      > resource@pcdata sheet.com
      > www.pcdatasheet.com
      >
      >
      > "chanchito_cojo nes" <cheeseortuna@h otmail.com> wrote in message
      > news:CEWSc.1668 031$Ar.475511@t wister01.bloor. is.net.cable.ro gers.com...[color=green]
      > > hi there,
      > >
      > > I am needing some help with a database I am putting together. The[/color][/color]
      database[color=blue][color=green]
      > > works off of a main Form, which then has buttons on it that will open up
      > > other forms. The problem I am having is that if I am updating any
      > > information on the current record, and then open one of the other forms,[/color][/color]
      the[color=blue][color=green]
      > > new form will not show the updated information. I realize that a simple
      > > macro solves this problem by basically closing the first form, opening[/color][/color]
      the[color=blue][color=green]
      > > new form, and then on exiting the new form opening the first one again.[/color][/color]
      The[color=blue][color=green]
      > > problem is, that with one of the sub forms that I need to open requires[/color][/color]
      some[color=blue][color=green]
      > > vb script with it. Here is the script:
      > >
      > > Private Sub INDIVIDUALSLIP_ Click()
      > > On Error GoTo Err_INDIVIDUALS LIP_Click
      > > Dim stDocName As String
      > > Dim stLinkCriteria As String
      > > stDocName = "frmIndividualS lip"
      > > DoCmd.OpenForm stDocName, , , stLinkCriteria, , , SlipID.Value
      > > Exit_INDIVIDUAL SLIP_Click:
      > > Exit Sub
      > >
      > > Err_INDIVIDUALS LIP_Click:
      > > MsgBox Err.Description
      > > Resume Exit_INDIVIDUAL SLIP_Click
      > > End Sub
      > >
      > >
      > > Now, I have tried playing around with the DoCmd.Close but I just cannot[/color][/color]
      seem[color=blue][color=green]
      > > to get it to work. It always ends up telling me that I am refering to
      > > something that doesn't exist or is already closed. So the help that I[/color][/color]
      am[color=blue][color=green]
      > > seeking is basically being able to have the script not only do what it[/color][/color]
      is[color=blue][color=green]
      > > currently doing, but also close the form so that the changes show when[/color][/color]
      the[color=blue][color=green]
      > > new forms opens up. However, I think I just had one of those "eureka"
      > > moments. I think I see what my problem is...hehe...The main form has
      > > specific ID values attached to each record, and when the[/color][/color]
      "frmIndividualS lip"[color=blue][color=green]
      > > is being called to open up, it is grabbing the ID value from the main[/color][/color]
      form[color=blue][color=green]
      > > (which is still open) so that it will retrieve the record that is being
      > > looked at in the main form. Which is what I need it to do. So, now that[/color][/color]
      I[color=blue][color=green]
      > > realize the obstacle that I am faced with, is there any way around it?[/color][/color]
      Am I[color=blue][color=green]
      > > able to have the record that has been updated in the main form, still
      > > populate itself in the new form that is being called to open, and still
      > > contain the updated values?
      > >
      > > I also realize that this problem can be solved by just going forward one
      > > record, and then coming back to the record that was updated, and then
      > > calling the new form to open it, thus showing the new values. And this[/color][/color]
      is[color=blue][color=green]
      > > what I have been doing, the only problem is that I know once I ask[/color][/color]
      people to[color=blue][color=green]
      > > use this database they may forget from time to time to do the whole[/color][/color]
      "forward[color=blue][color=green]
      > > then back".
      > >
      > > I really appreciate any help that can be offered.
      > >
      > > Thank You
      > >
      > >[/color]
      >
      >[/color]


      Comment

      Working...