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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form/Subform - Search Application - Subform Immediately Clears

Status
Not open for further replies.

HisEnergy

Programmer
Sep 25, 2006
5
US
I have a Main Form with unbound controls such as LastName, FirstName, City, State,... That I use to input my serach criteria.

On the Main Form is a Control Button Called "Search".

When I select "Search" with no Criteria in the unbound controls, I get a list of all records in the file in the subform.

But when I input for example - "Smith" in the LastName field and select "Search". The subform seems to display all records for Smith but immediately clears the Subform so as to appear there are no records for "Smith" in the File.

Any ideas as to why this is happening?

Thanks,

HisEnergy


 
check the events on the form and on the command button to see if you are clearing the subform somewhere...

best option is to step through the code when you do a search on smith...

--------------------
Procrastinate Now!
 
Crowley16 I tried this and it doesn't work.

Here is the VB Code for my Event Procedure for my Search Control Buttom.

Any Ideas?

Private Sub Search_Click()
Dim strWhere As String
Dim strError As String

strWhere = "1=1"

' If Last Name
If Nz(Me.LastNameTest) <> "" Then
'Add the predicate
strWhere = strWhere & " AND " & "Contacts.[Last Name] = '" & Me.LastName & "'"
End If

' If First Name
If Nz(Me.FirstName) <> "" Then
'Add the predicate
strWhere = strWhere & " AND " & "Contacts.[First Name] = '" & Me.FirstName & "'"
End If

' If Source ID
If Nz(Me.SourceID) <> "" Then
'Add the predicate
strWhere = strWhere & " AND " & "Contacts.[SourceID] = '" & Me.SourceID & "'"
End If

' If Ignite Status
If Nz(Me.IgniteStatus) <> "" Then
'Add the predicate
strWhere = strWhere & " AND " & "Contacts[Ignite Status] = '" & Me.IgniteStatus & "'"
End If

' If Associate ID
If Nz(Me.AssociateID) <> "" Then
'Add the predicate
strWhere = strWhere & " AND " & "Contacts.[Associate ID] = '" & Me.AssociateID & "'"
End If

' If MD
If Nz(Me.MD) <> "" Then
'Add the predicate
strWhere = strWhere & " AND " & "Contacts.[MD] = '" & Me.MD & "'"
End If

If strError <> "" Then
MsgBox strError
Else
'DoCmd.OpenForm "Browse Contacts", acFormDS, , strWhere, acFormEdit, acWindowNormal
If Not Me.FormFooter.Visible Then
Me.FormFooter.Visible = True
DoCmd.MoveSize Height:=Me.WindowHeight + Me.FormFooter.Height
End If
Me.Browse_All_Contacts.Form.Filter = strWhere
Me.Browse_All_Contacts.Form.FilterOn = True
End If
End Sub

Thanks

HisEnergy

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top