Setting a Field to Empty

J

Jado

Hi

i have a button on a form that checks the value/status of Field1

if i create a new record and use the button which has the following code..

Button1_OnClick()
If Me.Field1 <> "All Day" then
Me.Field2 = "Field1 is either AM or PM"
End if
End Sub

then nothing happens, Great!

Problem...

if i enter a value i Field1, but then remove it using the following code..

Button2_OnClick()
Field1 = Null
End Sub

then if i use button 1, Field2 is udpated with the value "Field1 is either
AM or PM".

is it possible to set the field back to the same state it was in before any
vale was entered?

i always thought this state was Null, but obviously not!

Thanks

Jado
 
G

Guest

Surely on a new record, clicking button 1 should show 'Field1 is either AM or
PM'
because Field1 is not "All Day" ?
If so, then it is the first bit of code that needs changing to

If IsNull(Me.Field1) Or Me.Field1 <> "All Day" then

Also I would change the button2 click code to

Field1 = ""
 
A

Alex Dybenko

To avoid confusin with Null you can use Nz function:

If nz(Me.Field1) <> "All Day" then
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top