Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / February 2006

Tip: Looking for answers? Try searching our database.

Why doesn't this work?  Just curious...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gina Whipp - 31 Jan 2006 14:44 GMT
Hello Anyone?

Why doesn't Example A work but Example B work?

Example A
   If Me.txtLength > 0 And Me.txtCoilListGauge > 0 And Not
IsNull(TPID(Forms![frmOrder]![cboCustomerID], [txtLength],
[txtCoilListGauge])) Then
       Me.txtTolling = TPID(Forms![frmOrder]![cboCustomerID], [txtLength],
[txtCoilListGauge]) & " lb."
       Me.txtEstimatedPieces.Requery
   Else
       Me.txtTolling = TollingPrice([txtLength], [txtCoilListGauge]) & "
lb."
       Me.txtEstimatedPieces.Requery
   End If

Example B
If Me.txtLength > 0 And Me.txtCoilListGauge > 0 And Not
IsNull(TPID(Forms![frmOrder]![cboCustomerID], [txtLength],
[txtCoilListGauge])) Then
       Me.txtTolling = TPID(Forms![frmOrder]![cboCustomerID], [txtLength],
[txtCoilListGauge]) & " lb."
       Me.txtEstimatedPieces.Requery
   End If

   If Me.txtLength > 0 And Me.txtCoilListGauge > 0 And
IsNull(TPID(Forms![frmOrder]![cboCustomerID], [txtLength],
[txtCoilListGauge])) Then
       Me.txtTolling = TollingPrice([txtLength], [txtCoilListGauge]) & "
lb."
       Me.txtEstimatedPieces.Requery
   End If

Thanks,
Gina
George Nicholson - 31 Jan 2006 18:03 GMT
In Example A, if either (or both) txtLength or txtCoilListGauge = 0, then
the condition is False and Me.txtTolling = TollingPrice([txtLength],
[txtCoilListGauge]). I'm guessing that means TollingPrice = 0.

In Example B, both txtLength and txtCoilListGauge have to be > 0 for
Me.txtTolling = TollingPrice([txtLength], [txtCoilListGauge]).

Maybe you want something like the following?:

If Me.txtLength > 0 And Me.txtCoilListGauge > 0 Then
     If Not IsNull(TPID(Forms![frmOrder]![cboCustomerID], [txtLength],
[txtCoilListGauge])) Then
       Me.txtTolling = TPID(Forms![frmOrder]![cboCustomerID], [txtLength],
[txtCoilListGauge]) & " lb."
   Else
       Me.txtTolling = TollingPrice([txtLength], [txtCoilListGauge]) & "
lb."
    End If
Else
       ' Not sure this is necessary....
       Me.txtTolling = 0
End If
Me.txtEstimatedPieces.Requery

HTH,
Signature

George Nicholson

Remove 'Junk' from return address.

> Hello Anyone?
>
[quoted text clipped - 32 lines]
> Thanks,
> Gina
Gina Whipp - 01 Feb 2006 01:02 GMT
I think maybe I should have been clearer.

Example A uses Else
Example B is 2 seperate statements

They both should come to the same conclusion, however, when I use the Else
statement it doesn't work.  If I seperate the logic into 2 statements it
works.

What I am saying is:

If [txtLength]>0 and [txtGauge]>0 and Not IsNull(TPID....)
then Me.txtTolling = TollingPrice(...)

OR

If [txtLength]>0 and [txtGauge]>0 and IsNull(TPID....)
then Me.txtTolling = TPID(...)

It's the Not IsNull / IsNull that is different.  Hope I expalined that
better.

Gina

> In Example A, if either (or both) txtLength or txtCoilListGauge = 0, then
> the condition is False and Me.txtTolling = TollingPrice([txtLength],
[quoted text clipped - 57 lines]
>> Thanks,
>> Gina
George Nicholson - 01 Feb 2006 01:57 GMT
You missed my point, but I could've been clearer. :-)

Your 2 examples start off the same but divurge significantly and will
provide different results

ExampleA - Part 1: If 1 ,2 and 3 are ALL True, do this.
ExampleA - Part 1: otherwise do this (i.e., if *any* or *all* of 1, 2, 3 are
False)

ExampleB - part 1: If 1, 2 and 3 are ALL True, do this.
ExampleB - part 2: If  both 1 and 2 are True and 3 is False, do this.

Your Part 1's are the same. Your Part 2's are not.  Example A will act, one
way or the other, on ALL permutations of the 3 conditions.  Example B only
acts on TTT and TTF. It does nothing with TFF, FTF, FFT and FFF
permutations. I have to assume the "do nothing" aspect is what you like
about the results of Example B (you never did provide a definition of "it
works", but I didn't ask either.).

Since it seems you only want to act when 1 and 2 are both True, I broke that
out as a primary condition. Only when that condition is met do you need to
do a nested 2nd check for Null and react accordingly.

HTH,
Signature

George Nicholson

Remove 'Junk' from return address.

>I think maybe I should have been clearer.
>
[quoted text clipped - 81 lines]
>>> Thanks,
>>> Gina
Gina Whipp - 01 Feb 2006 02:41 GMT
Okay, I understand now....  thanks for taking the time to explain it.  I
guess I didn't COMPLETELY read your answer.

Thanks,
Gina

> You missed my point, but I could've been clearer. :-)
>
[quoted text clipped - 106 lines]
>>>> Thanks,
>>>> Gina
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.