Show All Button

daisyoso

New Member
Joined
Aug 10, 2017
Messages
20
Hi Guys,

I have a search form which consist of a subform. After I tick the SEARCH button, I want to have a SHOW ALL button to show all my data. Please help.

Below are my search Combo Boxes:


Private Sub cbo_Doctype_AfterUpdate()
myDoc = "Select * from MainTable where ([Doc Type]= '" & Me.cbo_Doctype & "')"
Me.MainTable_subform.Form.RecordSource = myDoc
Me.MainTable_subform.Form.Requery
Me.cbo_Subcon = Null
Me.cbo_Status = Null
End Sub


Private Sub cbo_Subcon_AfterUpdate()
myDoc = "Select * from MainTable where ([Subcon]= '" & Me.cbo_Subcon & "')"
Me.MainTable_subform.Form.RecordSource = myDoc
Me.MainTable_subform.Form.Requery
Me.cbo_Doctype = Null
Me.cbo_Status = Null
End Sub

Private Sub cbo_Status_AfterUpdate()
myDoc = "Select * from MainTable where ([Status]= '" & Me.cbo_Status & "')"
Me.MainTable_subform.Form.RecordSource = myDoc
Me.MainTable_subform.Form.Requery
Me.cbo_Doctype = Null
Me.cbo_Subcon = Null
End Sub
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
I guess you have the button on the form already? Then perhaps
VBA Code:
Private Sub cbo_Doctype_AfterUpdate()

With Me
  .MainTable_subform.Form.RecordSource = "Select * from MainTable where ([Doc Type]= '" & Me.cbo_Doctype & "')"
  .MainTable_subform.Form.Requery
  .cbo_Subcon = Null
  .cbo_Status = Null
  .cmdSomeButtonNameHere.Visible = True
End With

End Sub
What makes the Show All button invisible? Why bother with visible or not? If the form shows all records and they click it, it does nothing. If not careful, you can end up with controls being invisible when you need and expect them to be visible.

I don't think you need the requery either. IIRC, setting the recordsource of a form performs an automatic requery.
 
Upvote 0
Hi Micron!

Thank you for the reply...I think i am not clear of my issue so here is the photo attached.

In the photo, I already Search the data per DOCUMENT TYPE (RFA Material). Now, I want a button "SHOW ALL" to show all my data again. Like unfilter everything again. I hope you get what I mean.

Thank you very much for the help!
 

Attachments

  • Untitled.png
    Untitled.png
    165.6 KB · Views: 7
Upvote 0
I'm just a tad confused. You say
I want to have a SHOW ALL button to show all my data
but you already have the button from what I see in the posted image (which is very small when I open it). Perhaps you want a button click event that has this in it for the button you already have?
VBA Code:
myDoc = "Select * from MainTable"
Me.MainTable_subform.Form.RecordSource = myDoc
Me.MainTable_subform.Form.Requery
That should show all records from MainTable.
 
Upvote 0
Solution
Hi Micron...that "Show All" button is not working.. thats why I am asking for help for this to work. Thank you for the code. I will try it!
 
Upvote 0
Hi Micron!!! problem solved!!! thank you very much for the help!!!!
@daisyoso - Glad to see you got the solution.
It is obvious the Requery method given as sample by @Micron is the generic solution by considering the minimal information provided in the original question. Therefore, I marked the post as the solution. That would be great if you could mark the solution posts when you receive an answer for your future questions (in fact even for your old questions if possible) to help future readers. Thanks.
 
Upvote 0

Forum statistics

Threads
1,215,007
Messages
6,122,670
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top