Checking Blank Time field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,
I have a Event Proc that runs on change of a field value from "open" to
"Closed" this macro checks a number of other fields to make sure they have
values before the "Closed" option can be set. I have no trouble checking the
text fields i just use if field = "" Then. Which works great but I need to
check a Date/time (General Date) type field and I cant seem to see how to
check if it is empty in the macro. I have tried "" " " & 0 but none of these
seem to work. Any one help?
 
Kitey

This would be very unusual if you find that it works correctly with your
text fields with if field = "". Are you sure? What is causing the
entry of a zero-length string ("") into these fields? I would imagine
that this would be the way to do it, regardless of the data type...
If IsNull(Me.ControlName) Then

By the way, this is not a macro.
 
Steve,
You will have to excuse me I am quite a beginner in the art of Macros VBA
and the like and wasn't sure what section this question would fit in. Perhaps
you could suggest the correct newsgroup should I have any other similar
questions.

Thanks for you answer. That did work for the time field.
The VBA I used for the text fields was

If Me!Status = "Closed" Then
If Me!Solution = "" Then
MsgBox ("Please add in the Solution to the problem")
Me!Status.Value = "Open"
End If
End If

As I said I'm not very knowledgeable about this but the above does seem to
work on a blank text field.

Thanks
Kitey
 
Kitey,

Macros are a particular type of database object in Access. To see what
they are all about, select the Macros tab on the Database Window, and
click New and you will go to the macro design window. Macros are
unrelated to VBA. I am happy to answer your question here, of course,
but maybe microsoft.public.access.formscoding or
microsoft.public.access.modulesdaovba may have been more applicable
newsgroups.

A field can be Null, i.e. there is nothing at all entered, or it can
have a zero-length string entered, which is "". In table design, you
can set the Allow Zero Length property of the field. It is set to No by
default, which is a very good thing, as normally you don't want a
zero-length string. In my experience, having a "" in a text field is
very unusual. If your code
If Me!Solution = "" Then
works, it means you have a zero-length string in the Solution field. I
wouldn't worry about it too much, if it works as required, but if it was
mine I would be trying to track down how the "" was getting in there,
and possibly fix it.
 
Back
Top