Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Double Click Error

Status
Not open for further replies.

aaabuhalime

Instructor
Nov 22, 2012
67
US
Hi every one ,
I have created two forms , form1 and form 2, form 1 consist of two fields to enter FName, and LName, and ok button, the ok button when clicked open the form2, form two consist of alist of records, and two button one to add contact and an other button to stop/cancel, the code I am using is listed below, the problem I am facing now is when I first open from 2, every thing works perfectly I can double click on any record an it opens just fine,then when I close the record that just browsed I can not open it again, or when I try to double click on any other record it doest do any thing , I have to close the whole thing and then reopen the form then I can double click on any othe record, and non of the button works as well, can any one help please, what I want is to able to do is be able to click on any rerod browse it and then click on the other record without the need to close the form and reopn it to be able to look at the other record, I hope it is clear. Many thanks in advance
Code:
Private Sub cmdOk_Click()


   'Me.Dirty = False
 DoCmd.Close acForm, "Form1"
End Sub





Private Sub Command6_Click()

    Me.Undo
    DoCmd.Close
    
End Sub

Public Function isOpen(ByVal strName As String, Optional intObjectType As Integer = acForm)
    isOpen = (SysCmd(acSysCmdGetObjectState, intObjectType, strName) <> 0)
End Function

Private Sub Form_AfterUpdate()
MsgBox "A new contact has been added."
DoCmd.OpenForm "frmContacts", acNormal, , "ContactID=" & ContactID

End Sub

Private Sub Form_BeforeUpdate(Cancel As Integer)
    Dim strSQL As String
    Dim strFrm As String

    strFrm = "Form2"

    DoCmd.OpenForm "Form2", acNormal, , , , acDialog
    '-----------------------------------------------------------------------------------
    ' If form2 is open, close it and do nothing else.
    ' Otherwise add a new record.
    '-----------------------------------------------------------------------------------
    If isOpen(strFrm) Then
        Cancel = True
        DoCmd.Close acForm, strFrm
        Me.Undo
    End If
    
End Sub
Code:
Private Sub cmdStop_Click()

    Me.Visible = False

End Sub
     


Private Sub Form_Load()

    Dim strSQL As String
    
    Page10.SetFocus
    
    strSQL = "select ContactID,LName, FName, City  from qryContacts where LName like ""*" & Forms!form1!txtLName & "*"" and FName like ""*" & Forms!form1!txtFName & "*"""
    List13.RowSource = strSQL
    
    If List13.ListCount > 0 Then
        Page11.SetFocus
    Else
        DoCmd.Close
    End If
    
End Sub


Private Sub List13_DblClick(Cancel As Integer)

    Stop
DoCmd.OpenForm "frmContacts", acNormal, , "ContactID=" & List13, , acDialog
MsgBox "Form2"


  Exit Sub


  Dim stDocName As String
  Dim stLinkCriteria As String
    stDocName = "frmContacts"
    
   stLinkCriteria = "[StringContactID]=" & "'" & Me![List13] & "'"
   
 ''stLinkCriteria = "[ParticipantID]=" & "'" & Me![ListGlow] & "'"
     
    DoCmd.OpenForm stDocName, , , stLinkCriteria, , acDialog
    
DoCmd.Close acForm, "frmContacts"

Exit_Command9_Click:
   Exit Sub
Err_Command9_Click:
   MsgBox Err.Description
   Resume Exit_Command9_Click
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top