If Then

  • Thread starter paulmitchell507
  • Start date
P

paulmitchell507

I am designing a small .asp (classic) application, I am connecting to
a Access 2k database via ADO to retrieve data. I have a number
variable's that contain text that is posted from a previous screen

AMPM = Request.Form("AMPM")
AMPMDate = Request.Form("AMPMDate")
halfday = "(" & AMPM & "," & AMPMDate & ")"

I then compose a CDOSYS email and send the value of the variable in
the .HTML body of the email

..HTML = "Number of Days" & halfday

What I would like to do is only display the value of the halfday
variable if it contains a value. I was thinking along the lines of

If halfday = Null Then
halfday = ""

Else

halfday = halfday

End if

I know this does not work, but it gives an idea of what I am trying to
achieve.
Any help would be appreciated.

Regards
 
B

Bob Barrows [MVP]

paulmitchell507 said:
I am designing a small .asp (classic) application, I am connecting to
a Access 2k database via ADO to retrieve data. I have a number
variable's that contain text that is posted from a previous screen

AMPM = Request.Form("AMPM")
AMPMDate = Request.Form("AMPMDate")
halfday = "(" & AMPM & "," & AMPMDate & ")"

I then compose a CDOSYS email and send the value of the variable in
the .HTML body of the email

.HTML = "Number of Days" & halfday

What I would like to do is only display the value of the halfday
variable if it contains a value. I was thinking along the lines of

If halfday = Null Then

This will never be true. Comparisons to Null always result in Null. You
probably mean:

If halfday Is Null Then

However, this will also never be the case at this point because in your
previous statements, you assigned values to halfday. I think what you
intend to do is something like;

If AMPM = "" And AMPMDate = "" then
halfday=""
Else
halfday = "(" & AMPM & "," & AMPMDate & ")"
End if
 
A

Anthony Jones

Bob Barrows said:
This will never be true. Comparisons to Null always result in Null. You
probably mean:

If halfday Is Null Then

Your VBScript getting a bit rusty Bob? ;)

If IsNull(halfday) Then

The Is keyword in VBScript tests the type of an object (via the
QueryInterface method).
 
P

paulmitchell507

Your VBScript getting a bit rusty Bob? ;)

If IsNull(halfday) Then

The Is keyword in VBScript tests the type of an object (via the
QueryInterface method).

Bob's VBScript may/may not be a bit rusty (I am not qualified to
judge, hence my question) but it worked for me!
Thank you both very much for your help.
 
B

Bob Barrows [MVP]

Anthony said:
Your VBScript getting a bit rusty Bob? ;)

If IsNull(halfday) Then

The Is keyword in VBScript tests the type of an object (via the
QueryInterface method).

Oops. Doing too much sql lately ...
 

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

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top