Allowing selection of null from combobox (1 Viewer)

Msmartine

Registered User.
Local time
Today, 15:05
Joined
Sep 15, 2014
Messages
26
I am definitely using the combo box's recordsource as the Status table. My AfterUpdate code is as follows:

Code:
Private Sub CboStatus_AfterUpdate()
Dim mystatus As String
mystatus = "Select * from tblFGTracking where ([status] = '" & Me.CboStatus & "')"
Me.tblFGTracking_subform.Form.RecordSource = mystatus
Me.tblFGTracking_subform.Form.Requery
Me.Total = FindRecordCount(mystatus)
End Sub
 

Isaac

Lifelong Learner
Local time
Today, 12:05
Joined
Mar 14, 2017
Messages
8,784
I am definitely using the combo box's recordsource as the Status table. My AfterUpdate code is as follows:
I meant recordsource of form. Ok yes, so your code might change to:
Code:
Private Sub CboStatus_AfterUpdate()
Dim mystatus As String
if Me.CboStatus ="Blank" then
    mystatus="Select * from tblFGTracking where [status]='' or [status] is null"
else
    mystatus = "Select * from tblFGTracking where ([status] = '" & Me.CboStatus & "')"
end if
Me.tblFGTracking_subform.Form.RecordSource = mystatus
Me.tblFGTracking_subform.Form.Requery
Me.Total = FindRecordCount(mystatus)
End Sub
...and you would need to add the record with value "Blank" into the table that is the rowsource of the combo box.
 

Msmartine

Registered User.
Local time
Today, 15:05
Joined
Sep 15, 2014
Messages
26
That worked perfectly! Thank you!
 

Users who are viewing this thread

Top Bottom