MS-Access Query to compare to show all records where Form Combo value is selected

Mohsin Malik

Registered User.
Local time
Today, 23:54
Joined
Mar 25, 2012
Messages
179
Hello,

I am building a tracking database where we would be able to track information which field are null data and report them to our Administration to fill the null data. For this I have created a form name "Search" and
I have a combo box control on that form which is bound to "Table = employee" and its ROW SOURCE TYPE="Field List", I would like to able to query records where the selected value in this combo box is null through out the table.

For example if I select "Telephone" from this combo box dropdown, I would like the query to show all the records where the "Telephone" is null, can you please advise how to set the criteria in query to take the combo box value as "Field Name" and then compare it with the Field/Column in the table and show the null values.

Thank you
Mohsin
 
strSQL="SELECT * FROM tblYourTable WHERE " & [Me.cboFields] & " Is Null"
 
strSQL="SELECT * FROM tblYourTable WHERE " & [Me.cboFields] & " Is Null"



Dear Cronk,

Thank you for the reply can you please guide me further to get it worked, I have tried this in Microsoft Access query SQL View and it does not work. Is there any possibility that if I would run the Access report with command button click on form it would filter out the report result where [Me.cboFields] is null, I am not sure how to apply criteria based on the combo box value as field name not as value? I really appreciate you help in this.

Thank you
Mohsin
 
You did post in the VBA section. You probably would have received a different solution had you posted in the Queries section.

Anyway, make the combo unbound. In the AfterUpdate event of your combo, have the following code

Code:
strSQL="select * into tblYourOutput from tblYourTable where " & me.cboYourCombo & " Is Null"
currentdb.execute strSQL

That will generate a table containing the records with the null in the field selected.
 

Users who are viewing this thread

Back
Top Bottom