Hello there, I am very new to these forums and have a problem which I have been unable to resolve myself so would like some assistance to resolve if possible.
Background - I have a movie database and have created a form with numerous combobox and radio button controls in the header which are used to filter the records. These are all working very well. One of the combobox controls is called status and has values New, Premier, Selected and ???. I use these when choosing a film I might want to watch. I also leave the field blank when I don't require a value to be entered. I have used the following SQL to filter which works well:
Like IIf([Forms]![frmMovies]![cbxStatusID]="<ALL>","*",[Forms]![frmMovies]![cbxStatusID])
This will show all records or the specific selected value. Now I will confess that I had to create a new column in the query as follows to allow for the null values which ensured all records were returned and the blank ones were not ignored:
Nz([Status],0)
The above column is where the criteria filter SQL is entered. Now to my problem. I would also like to filter out all the records that were null (or now have 0) just showing the records that have a value. So rather than just seeing New or Premier or Selected I want to see all of these but not the blank ones. My combobox for applying the filter is populated using the following:
SELECT DISTINCT Status.StatusID, Status.Status FROM Status UNION SELECT "0", "<ALL>" FROM Status UNION SELECT "0","<Not Null>" FROM Status ORDER BY Status.Status;
So I have also added <All> and <Not Null> to the list for selection. I have tried the following but cannot get the result I want:
Like IIf([Forms]![frmMovies]![cbxStatusID]="<ALL>","*",IIf([Forms]![frmMovies]![cbxStatusID]="<Not Null>",<> '0',[Forms]![frmMovies]![cbxStatusID]))
If I just use the following, without the IIF statement, I get exactly what I want but without the individual or all availability:
<>'0'
I assumed the logic would be if <Not Null> was selected that the <>'0' would be used and filter out all the null valued records in the same way that selecting <ALL> filters for all records as the "*" is used.
I also tried these alternatives:
Like IIf([Forms]![frmMovies]![cbxStatusID]="<ALL>","*",IIf([Forms]![frmMovies]![cbxStatusID]="<Not Null>",Not Like '0',[Forms]![frmMovies]![cbxStatusID]))
Like IIf([Forms]![frmMovies]![cbxStatusID]="<ALL>","*",IIf([Forms]![frmMovies]![cbxStatusID]="<Not Null>",(Nz([Status],0)) Not Like '0',[Forms]![frmMovies]![cbxStatusID]))
But the Not Like does not work either.
Can anyone point me in the right direction as to what I should put instead of <>'0' as the True part of the IIf statement?
Background - I have a movie database and have created a form with numerous combobox and radio button controls in the header which are used to filter the records. These are all working very well. One of the combobox controls is called status and has values New, Premier, Selected and ???. I use these when choosing a film I might want to watch. I also leave the field blank when I don't require a value to be entered. I have used the following SQL to filter which works well:
Like IIf([Forms]![frmMovies]![cbxStatusID]="<ALL>","*",[Forms]![frmMovies]![cbxStatusID])
This will show all records or the specific selected value. Now I will confess that I had to create a new column in the query as follows to allow for the null values which ensured all records were returned and the blank ones were not ignored:
Nz([Status],0)
The above column is where the criteria filter SQL is entered. Now to my problem. I would also like to filter out all the records that were null (or now have 0) just showing the records that have a value. So rather than just seeing New or Premier or Selected I want to see all of these but not the blank ones. My combobox for applying the filter is populated using the following:
SELECT DISTINCT Status.StatusID, Status.Status FROM Status UNION SELECT "0", "<ALL>" FROM Status UNION SELECT "0","<Not Null>" FROM Status ORDER BY Status.Status;
So I have also added <All> and <Not Null> to the list for selection. I have tried the following but cannot get the result I want:
Like IIf([Forms]![frmMovies]![cbxStatusID]="<ALL>","*",IIf([Forms]![frmMovies]![cbxStatusID]="<Not Null>",<> '0',[Forms]![frmMovies]![cbxStatusID]))
If I just use the following, without the IIF statement, I get exactly what I want but without the individual or all availability:
<>'0'
I assumed the logic would be if <Not Null> was selected that the <>'0' would be used and filter out all the null valued records in the same way that selecting <ALL> filters for all records as the "*" is used.
I also tried these alternatives:
Like IIf([Forms]![frmMovies]![cbxStatusID]="<ALL>","*",IIf([Forms]![frmMovies]![cbxStatusID]="<Not Null>",Not Like '0',[Forms]![frmMovies]![cbxStatusID]))
Like IIf([Forms]![frmMovies]![cbxStatusID]="<ALL>","*",IIf([Forms]![frmMovies]![cbxStatusID]="<Not Null>",(Nz([Status],0)) Not Like '0',[Forms]![frmMovies]![cbxStatusID]))
But the Not Like does not work either.
Can anyone point me in the right direction as to what I should put instead of <>'0' as the True part of the IIf statement?