Search empty field

Z

Zaradi Zakaria

Hi,

Thanks for organizing this great web forum, hope this will settle my problem.
I've created a form with search command button with code;
Me.Filter = "[YourFieldName]='" & YourFilterValue & "'"
Me.FilterOn = True

Normally I use this code to search any value in 'YourFieldName'. It's work
fine unless if you trying to use for empty field. When I use the field to
put value =Now() contains Date&Time format ,sadly my search button does'nt
work to search for any empty value in that field. I''ve tried Is Null/Null/ "
" but it still does'nt work.

Second, how can I lock value from overwriten by new value. I've use command
button to update new date. But I do'nt want user to overwrite with previous
value(date).

So any suggestions appreciated.


Thanks in advance.

Eddy
 
M

MacDermott

First, if your field contains a date/time format, your filter should look
like this:
Me.Filter = "[YourFieldName]=#" & YourFilterValue & "#"

To include a null search (assuming YourFilterValue is a string), you might
have to code something like this:
If YourFilterValue="" then
Me.Filter = "[YourFieldName] Is Null"
Else
Me.Filter = "[YourFieldName]=#" & YourFilterValue & "#"
EndIf

As for locking, you can set your textbox's Locked property to Yes.
You'll still be able to change the value programmatically, but the user
won't be able to type directly into the field.

HTH
 
Top