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

Filter issue 1

Status
Not open for further replies.

44nato44

Programmer
Dec 12, 2008
115
NL
Hi

I have a form with a sub form, which is used to make a search/filter list with.

After this the user will click the filtered sublist, by clicking on the ID field

No matter which field is clicked on then the top value on the list is chosen.

Anybody has a good idea ?

Cheers
 
??? No idea what you just said. Please reword clearly, and provide all applicable code. Well written questions get good answers.
 
sure :eek:)

I have abutton on the main form, which is do a requery on the sub form.. which then run the below code to change the filter on the sub form.

I hope this is a bit more clear ?

This is on Current on the sub form

Private Sub Form_Current()
Dim fltstr As String

' Build SQL String

If Len(Forms!FRM_InvoiceList!txtfltInvoiceNo) > 0 Then
fltstr = " [InvoiceID] = " & Forms!FRM_InvoiceList!txtfltInvoiceNo & " AND "
End If

If Len(Forms!FRM_InvoiceList!txtfltamount) > 0 Then
fltstr = fltstr & "[Amount] = " & Forms!FRM_InvoiceList!txtfltamount & " AND "
End If

If Len(Forms!FRM_InvoiceList!cbofltsupplier) > 0 Then
fltstr = fltstr & "[Supplier] = '" & Forms!FRM_InvoiceList!cbofltsupplier & "' AND "
End If

If Len(Forms!FRM_InvoiceList!cboCostElementCode) > 0 Then
fltstr = fltstr & "[CostElement] = " & Forms!FRM_InvoiceList!cboCostElementCode.Column(0) & " AND "
End If

If Len(fltstr) > 1 Then
fltstr = Left(fltstr, Len(fltstr) - 4)
MsgBox fltstr
Me.Filter = fltstr
Me.FilterOn = True
Else
Me.Filter = "[InvoiceID] > 0"
Me.FilterOn = True
End If
End Sub
 
That was about the only part I understood.

I have no idea what this means:

After this the user will click the filtered sublist, by clicking on the ID field
No matter which field is clicked on then the top value on the list is chosen

What list?
What do you expect to happen?
 
the filter will generate a datasheet list in the subform, I made it so if the user click on the ID field then it will take that ID field that the user click on... at the moment for my testing it just open a msgbox

What happen now is that it picks the value on the top of the list and not the value which is being clicked on

I hope this makes more sense ?
 
44nato44 said:
This is on Current on the sub form
Code:
Private Sub Form_Current()
I can't imagine why the code would be in the On Current of the subform. This would set the filter every time you moved from record to record in the subform.

Typically you will set all the filter values in the main form and have code in the main form that sets the filter or record source of the subform.

Duane
Hook'D on Access
MS Access MVP
 
Greeeat thanks a lot.

I allways put it in the sub form and it has allways given trouble.. so you opened my eyes.

I hope you have a good day.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top