If...and

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

Guest

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
 
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
 
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
 
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
 
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
 

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

Back
Top