Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Silly fundamental VB question -- IF something AND something THEN -- is't possible?


Message #1 by "Susan Henesy" <susan.henesy@w...> on Fri, 20 Apr 2001 00:32:09
Hello gurus,



This is not the first time I've run into an AND OR problem with VB 

statements, but now that I've got a whole network of experts to talk to, I 

thought I'd ask -- since this monster has raised its unattractive head 

again -- is it even POSSIBLE to write an IF statment with an AND or an OR 

in it?



Here's what's not working:



If Request.Form("MyField") = "Other" AND Request.Form("MyOtherField") = "" 

Then 

  Response.Write "You selected OTHER without giving us a description! " & _

   "Click your BACK button to correct your entry and try again."

End If



I've also tried using:



If Request.Form("MyField")="Other" AND Len(Request.Form("MyOtherField"))=0 

Then

   'Write a note to user

End If



But still to no effect.  VB just ignores the AND statement and gives a 

message out even if the second field has got text written in it.



Help! 



Susan









Message #2 by "Charles Feduke" <webmaster@r...> on Thu, 19 Apr 2001 21:33:31 -0400
    I get the same thing myself all the time.  I'll stare and an If with an

And and a (... Or ...) and not have stuff work.  Makes me really mad.  Must

be my old age (22).



    Make sure your other field is really "MyOtherField" (or whatever you

named it).  Copy and paste from one place to another if you have to.  I once

spent hours on a SQL bug because I spelled UPDATE  as UDPATE.  I thought I

was going crazy.  It sounds to me that Request.Form("MyOtherField") has

"MyOtherField" spelled wrong or not even passed (make sure MyOtherField is

contained in the FORM tags in you page!).  I bet if you do a

IsNull(Request.Form("MyOtherField")) it will return True, meaning it is...

tada!:  Null.  (Len(vbNullString) = Null or > 0, not totally sure; "" <>

vbNullString)



- Chuck



----- Original Message -----

From: "Susan Henesy" <susan.henesy@w...>

To: "ASP Databases" <asp_databases@p...>

Sent: Friday, April 20, 2001 12:32 AM

Subject: [asp_databases] Silly fundamental VB question -- IF something AND

something THEN -- is't possible?





> Hello gurus,

>

> This is not the first time I've run into an AND OR problem with VB

> statements, but now that I've got a whole network of experts to talk to, I

> thought I'd ask -- since this monster has raised its unattractive head

> again -- is it even POSSIBLE to write an IF statment with an AND or an OR

> in it?

>

> Here's what's not working:

>

> If Request.Form("MyField") = "Other" AND Request.Form("MyOtherField") = ""

> Then

>   Response.Write "You selected OTHER without giving us a description! " &

_

>    "Click your BACK button to correct your entry and try again."

> End If

>

> I've also tried using:

>

> If Request.Form("MyField")="Other" AND Len(Request.Form("MyOtherField"))=0

> Then

>    'Write a note to user

> End If

>

> But still to no effect.  VB just ignores the AND statement and gives a

> message out even if the second field has got text written in it.

>

> Help!

>

> Susan



Message #3 by "Susan Henesy" <susan.henesy@w...> on Fri, 20 Apr 2001 01:18:50
Greetings,



I am popping back in to say I answered my own question.



I said that this statement wasn't working:

********************************************

> If Request.Form("MyField") = "Other" AND Request.Form("MyOtherField") 

= "" 

> Then 

>   Response.Write "You selected OTHER without giving us a description! " 

& _

>    "Click your BACK button to correct your entry and try again."

> End If

********************************************



And the reason it wasn't working was because I'd named the field on the 

previous form something COMPLETELY different!!  That'll mess up things up 

every time :).



Anyway, problem solved, never mind! :)

Susan
Message #4 by "Susan Henesy" <susan.henesy@w...> on Fri, 20 Apr 2001 23:20:39
'****************************************************

>     I get the same thing myself all the time.  I'll stare and an If with 

an

> And and a (... Or ...) and not have stuff work.  Makes me really mad.  

Must

> be my old age (22).

> 

>     Make sure your other field is really "MyOtherField" (or whatever you

> named it).  Copy and paste from one place to another if you have to.  I 

once

> spent hours on a SQL bug because I spelled UPDATE  as UDPATE.  I thought 

I

> was going crazy.  It sounds to me that Request.Form("MyOtherField") has

> "MyOtherField" spelled wrong or not even passed (make sure MyOtherField 

is

> contained in the FORM tags in you page

'****************************************************



Charles,



As you can see from my previous message, you were ABSOLUTELY correct!  I 

had misnamed the field in the previous form.  I've been doing a lot of 

this "I must be going out of my mind" stuff since I started these ASP 

pages of mine.  One day last week I spent TWO HOURS nearly IN TEARS as I 

tried to find the reason why a particular page just wouldn't work!!  The 

reason???  



<INPUT TYPE="text" NAME="Field1" VALUE="<%objRS("Field1")%>">



I could not find that missing equal sign to save my life!!!!!  Well, not 

for 2 or more hours, at least!!  ARRRGGGH!!



Thank you for feeling my pain :),

Susan  

Message #5 by "Tomm Matthis" <matthis@b...> on Sat, 21 Apr 2001 10:48:38 -0400
Susan, I know what you're saying!!! My advice: After a certain amount of

frustration, it *does* get easier!!



-- Tomm



> -----Original Message-----

> From: Susan Henesy [mailto:susan.henesy@w...]

> Sent: Friday, April 20, 2001 11:21 PM

> To: ASP Databases

> Subject: [asp_databases] Re: Silly fundamental VB question -- IF

> something AND something THEN -- is't possible?

>

>

> '****************************************************

> >     I get the same thing myself all the time.  I'll stare and

> an If with

> an

> > And and a (... Or ...) and not have stuff work.  Makes me really mad.

> Must

> > be my old age (22).

> >

> >     Make sure your other field is really "MyOtherField" (or whatever you

> > named it).  Copy and paste from one place to another if you have to.  I

> once

> > spent hours on a SQL bug because I spelled UPDATE  as UDPATE.

> I thought

> I

> > was going crazy.  It sounds to me that Request.Form("MyOtherField") has

> > "MyOtherField" spelled wrong or not even passed (make sure MyOtherField

> is

> > contained in the FORM tags in you page

> '****************************************************

>

> Charles,

>

> As you can see from my previous message, you were ABSOLUTELY correct!  I

> had misnamed the field in the previous form.  I've been doing a lot of

> this "I must be going out of my mind" stuff since I started these ASP

> pages of mine.  One day last week I spent TWO HOURS nearly IN TEARS as I

> tried to find the reason why a particular page just wouldn't work!!  The

> reason???

>

> <INPUT TYPE="text" NAME="Field1" VALUE="<%objRS("Field1")%>">

>

> I could not find that missing equal sign to save my life!!!!!  Well, not

> for 2 or more hours, at least!!  ARRRGGGH!!

>

> Thank you for feeling my pain :),

> Susan

>

> 

  Return to Index