If...and

R

RFrechette

I am trying to create VB Code for a form that says...

If [Status] = "Complete" And [Ended] Is Not Null Then

[Complete] = "Yes"

Else

[Complete] = "No"

End If

Status is a text field, Ended is a date field, and Complete is a text field.
I can't get it to work and all the books I've tried do not help me.

Can someone please tell me what I am doing wrong. I'm getting desperate.

Thank you.

Rachel
 
R

RoyVidar

RFrechette said:
I am trying to create VB Code for a form that says...

If [Status] = "Complete" And [Ended] Is Not Null Then

[Complete] = "Yes"

Else

[Complete] = "No"

End If

Status is a text field, Ended is a date field, and Complete is a text
field. I can't get it to work and all the books I've tried do not
help me.

Can someone please tell me what I am doing wrong. I'm getting
desperate.

Thank you.

Rachel

Try something like this

If Me!Status = "Complete" And Not IsNull(Me!Ended) Then
Me!Complete = "Yes"
Else
Me!Complete = "No"
End If

Is Null is SQL syntax, while the IsNull function more usable in VBA
 
D

Douglas J. Steele

In VBA, you need to use the IsNull function, not the Is Not Null expression
from SQL:

If [Status] = "Complete" And IsNull([Ended]) = False Then

[Complete] = "Yes"

Else

[Complete] = "No"

End If
 
R

RFrechette

Thank you so much. That worked.

Rachel

RoyVidar said:
RFrechette said:
I am trying to create VB Code for a form that says...

If [Status] = "Complete" And [Ended] Is Not Null Then

[Complete] = "Yes"

Else

[Complete] = "No"

End If

Status is a text field, Ended is a date field, and Complete is a text
field. I can't get it to work and all the books I've tried do not
help me.

Can someone please tell me what I am doing wrong. I'm getting
desperate.

Thank you.

Rachel

Try something like this

If Me!Status = "Complete" And Not IsNull(Me!Ended) Then
Me!Complete = "Yes"
Else
Me!Complete = "No"
End If

Is Null is SQL syntax, while the IsNull function more usable in VBA
 
R

RFrechette

Thank you very much. That worked.

Rachel

Douglas J. Steele said:
In VBA, you need to use the IsNull function, not the Is Not Null expression
from SQL:

If [Status] = "Complete" And IsNull([Ended]) = False Then

[Complete] = "Yes"

Else

[Complete] = "No"

End If


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


RFrechette said:
I am trying to create VB Code for a form that says...

If [Status] = "Complete" And [Ended] Is Not Null Then

[Complete] = "Yes"

Else

[Complete] = "No"

End If

Status is a text field, Ended is a date field, and Complete is a text
field.
I can't get it to work and all the books I've tried do not help me.

Can someone please tell me what I am doing wrong. I'm getting desperate.

Thank you.

Rachel
 
Top