Results 1 to 3 of 3
  1. #1
    Join Date
    May 2004
    Posts
    38

    Unanswered: Odd behaviour from form

    Hello

    I have form which has two unbound combo boxes one which holds job numbers and another names.

    I have a button which searches these criterias either seperatly or together.

    However when I go to the drop down boxes and select an item and then click search the form closes and nothing happens, then if I reopen the form and select the same item as before and click search it opens the correct form with the record found.

    Does anyone know why I have to do this action twice to find the record?

    Thank you in advance

  2. #2
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    Are you opening another form to show the results? If so, how are you passing the selections to the form? In OpenArgs or in a table?

  3. #3
    Join Date
    May 2004
    Posts
    38

    my code from the odd behaviour

    Here is my code - I open the records which have been found in a seperate form. But for some reason it doesn't open untill i reopen the search form after it has closed iteself. However i have other search forms for other areas of my database and it works fine.

    Code:
    Private Sub FindOrder_Click()
       ' Search - build a new filter string
        gstrWhereCust = ""
        
        If Not IsNothing(Me!JobNumber) Then
            gstrWhereCust = "[JobNumber] Like " & Chr$(34) & Me!JobNumber
            If Right$(Me!JobNumber, 0) = "*" Then
                gstrWhereCust = gstrWhereCust & Chr$(34)
            Else
                gstrWhereCust = gstrWhereCust & "*" & Chr$(34)
            End If
        End If
    
        If Not IsNothing(Me!CustomerReference) Then
            'If IsNothing(gstrWhereCust) Then
                gstrWhereCust = "[CustomerReference] Like " & Chr$(34) & Me!CustomerReference
            'Else
              '  gstrWhereCust = gstrWhereCust & " AND [CustomerReference] Like " & Chr$(34) & Me!CustomerReference
           ' End If
            If Right$(Me!CustomerReference, 0) = "*" Then
                gstrWhereCust = gstrWhereCust & Chr$(34)
            Else
                gstrWhereCust = gstrWhereCust & "*" & Chr$(34)
            End If
        End If
        
        ' If no criteria, then nothing to do...
        If IsNothing(gstrWhereCust) Then
            MsgBox "No criteria specified.", vbExclamation, "Paramount Marble"
            Exit Sub
        End If
    
        ' Hide myself and turn on Hourglass
        Me.Visible = False
        DoCmd.Hourglass True
        If IsLoaded("Orders") Then  ' If customers form already open (it should be),
            ' Then just filter it
            Forms!Orders.SetFocus
            DoCmd.ApplyFilter , gstrWhereCust
            If Forms!Orders.RecordsetClone.RecordCount = 0 Then
                DoCmd.Hourglass False
                MsgBox "No Orders meet your criteria", vbExclamation, "Paramount Marble"
                DoCmd.ShowAllRecords
                'If gintIsAdmin Then
                    'Forms!Customer!Add.Visible = True
                    'Else
                   ' Forms!frmCustomers!cmdAddNew.Visible = False
                'End If
                'Forms!Customer!Show.Visible = False
                Me.Visible = True
                Exit Sub
            End If
            
           ' Forms!Customer!Add.Visible = False
           ' Forms!Customer!Show.Visible = True
            DoCmd.Hourglass False
        Else
            ' Find out if any customers satisfy the Where clause
            DoCmd.Hourglass True
            DoCmd.OpenForm FormName:="Orders", WhereCondition:=gstrWhereCust, _
                WindowMode:=acHidden
            If Forms!Orders.RecordsetClone.RecordCount = 0 Then
                DoCmd.Hourglass False
                MsgBox "No Orders meet your criteria", vbExclamation, "Paramount Marble"
                DoCmd.Close acForm, "Orders"
                Me.Visible = True
                Exit Sub
            End If
            DoCmd.Hourglass False
            'Forms!Customer!Add.Visible = False
            'Forms!Customer!Show.Visible = True
            'Forms!Customer.Visible = True
        End If
        ' Close me, and we're done
        DoCmd.Close acForm, Me.Name
    
    
    End Sub
    Cheers

Posting Permissions

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