Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2003
    Posts
    4

    Unanswered: Good code gone bad?

    I have the following code within my database. The user reviews a directory of contacts. Once they find the contact they want, they click a button and the form for that contact comes up with all that contact's info.

    For the last year, this code has worked flawlessly. If the user clicked the button and the contact form came up then they clicked the button again for another contact, the second contact form would replace the first. Now if a user clicks the button, the contact form does come up but when they click the button again for another contact, nothing happens. It stays on the intial contact form unless it is closed. How come it worked before but not now? I have already taken the code out, compacted the database, put the code back in and compacted again, but it just doesn't work. HELP!

    Private Sub cmdbtnGo_To_This_Contact_Click()
    DoCmd.OpenForm "frmMC_Main", acNormal, , "[MC_SN] = [Forms]![frmMC_Directory]![MC_SN]", , acWindowNormal
    End Sub

  2. #2
    Join Date
    Feb 2004
    Posts
    37
    Try
    Private Sub cmdbtnGo_To_This_Contact_Click()
    DoCmd.OpenForm "frmMC_Main", acNormal, , "[MC_SN] = [Forms]![frmMC_Directory]![MC_SN]", , acWindowNormal
    frmmc_main.refresh
    End Sub

    or

    Try closing the form first (its more overhead, but shoud work - acSaveNo, means it will not save or prompt save, you can also have acSaveYes or acSavePrompt):
    Private Sub cmdbtnGo_To_This_Contact_Click()
    DoCmd.close acForm, "form_name", acSaveNo
    DoCmd.OpenForm "frmMC_Main", acNormal, , "[MC_SN] = [Forms]![frmMC_Directory]![MC_SN]", , acWindowNormal
    End Sub

    Brian.

  3. #3
    Join Date
    Sep 2003
    Posts
    4
    Thank you. Closing the form worked. Why do you suppose it would have worked before without the "close" but now it doesn't?

    Originally posted by brianb99999
    Try
    Private Sub cmdbtnGo_To_This_Contact_Click()
    DoCmd.OpenForm "frmMC_Main", acNormal, , "[MC_SN] = [Forms]![frmMC_Directory]![MC_SN]", , acWindowNormal
    frmmc_main.refresh
    End Sub

    or

    Try closing the form first (its more overhead, but shoud work - acSaveNo, means it will not save or prompt save, you can also have acSaveYes or acSavePrompt):
    Private Sub cmdbtnGo_To_This_Contact_Click()
    DoCmd.close acForm, "form_name", acSaveNo
    DoCmd.OpenForm "frmMC_Main", acNormal, , "[MC_SN] = [Forms]![frmMC_Directory]![MC_SN]", , acWindowNormal
    End Sub

    Brian.

  4. #4
    Join Date
    Feb 2004
    Posts
    37
    Access is a strange beast!

Posting Permissions

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