Strange Behavior 
Author Message
 Strange Behavior

Greetings,
        I have a dilemma in respect to a combo box on a form.  I am attempting to
check a certain combo box ("cboPayableTerm") to see if it's equal to null.
If it is, then I want to display a message box and then exit the
subroutine.  The following code, however, doesn't seem to work.  
        I have stepped through the code and the combo box seems to be evaluating
to null alright, but for some strange reason it jumps to the end of the
"IF" statement and keeps executing the subroutine.  Is there something
blatantly obvious that I'm doing wrong?  Or does it have anything to do
with the way I am referencing the control on the form?  Any advice you can
give is most appreciated.  The code I currently have is listed below.  

Thanks in advance,

Sherwood Page

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

Private Sub cmdLeaseInvoice_Sheet_Click()
    ' Assign the name of the current form to a variable.  This variable is
    ' used in another module sheet.
    current_form = Me.Name
    ' Check to see if the combo box is null.
    If Me.cboPayableTerm = Null Then
        MsgBox "'Payable\Receivable' field must not be left blank"
        Exit Sub
    End If
    ' Open the following report
    DoCmd.OpenReport "rpt-LEASE RENTAL RECORD/INVOICE", acViewPreview
End Sub

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

By the way, I have also tried the following in place of the second line of
code, but all to no avail:

1)  If Forms(current_form).[cboPayable_Receivable] = Null then
2)  If Me.cboPayable_Receivable.Value = Null Then
3)  If Me.[cboPayable_Receivable].Value = Null Then
--



Mon, 22 Jul 2002 03:00:00 GMT  
 Strange Behavior
Does this work:

   If IsNull(Me.cboPayableTerm) Then
       '...

?
--

Dirk Goldgar
(remove NOSPAM from reply address)


Quote:
> Greetings,
> I have a dilemma in respect to a combo box on a form.  I am attempting to
> check a certain combo box ("cboPayableTerm") to see if it's equal to null.
> If it is, then I want to display a message box and then exit the
> subroutine.  The following code, however, doesn't seem to work.
> I have stepped through the code and the combo box seems to be evaluating
> to null alright, but for some strange reason it jumps to the end of the
> "IF" statement and keeps executing the subroutine.  Is there something
> blatantly obvious that I'm doing wrong?  Or does it have anything to do
> with the way I am referencing the control on the form?  Any advice you can
> give is most appreciated.  The code I currently have is listed below.

> Thanks in advance,

> Sherwood Page

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

- Show quoted text -

Quote:
> ********

> Private Sub cmdLeaseInvoice_Sheet_Click()
>     ' Assign the name of the current form to a variable.  This variable is
>     ' used in another module sheet.
>     current_form = Me.Name
>     ' Check to see if the combo box is null.
>     If Me.cboPayableTerm = Null Then
>         MsgBox "'Payable\Receivable' field must not be left blank"
>         Exit Sub
>     End If
>     ' Open the following report
>     DoCmd.OpenReport "rpt-LEASE RENTAL RECORD/INVOICE", acViewPreview
> End Sub

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

- Show quoted text -

Quote:
> *********************

> By the way, I have also tried the following in place of the second line of
> code, but all to no avail:

> 1)  If Forms(current_form).[cboPayable_Receivable] = Null then
> 2)  If Me.cboPayable_Receivable.Value = Null Then
> 3)  If Me.[cboPayable_Receivable].Value = Null Then
> --



Mon, 22 Jul 2002 03:00:00 GMT  
 Strange Behavior
You need to make the following alteration:

If IsNull(Me!cboPayableTerm) Then

There are two alterations. Firstly, null never equals null, so you need to
use IsnUll, which returns true/false. Secondly, you should use the bang
operator for controls, and the dot for object properties.
--

HTH

Jon


Quote:
> Greetings,
> I have a dilemma in respect to a combo box on a form.  I am attempting to
> check a certain combo box ("cboPayableTerm") to see if it's equal to null.
> If it is, then I want to display a message box and then exit the
> subroutine.  The following code, however, doesn't seem to work.
> I have stepped through the code and the combo box seems to be evaluating
> to null alright, but for some strange reason it jumps to the end of the
> "IF" statement and keeps executing the subroutine.  Is there something
> blatantly obvious that I'm doing wrong?  Or does it have anything to do
> with the way I am referencing the control on the form?  Any advice you can
> give is most appreciated.  The code I currently have is listed below.

> Thanks in advance,

> Sherwood Page

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

- Show quoted text -

Quote:
> ********

> Private Sub cmdLeaseInvoice_Sheet_Click()
>     ' Assign the name of the current form to a variable.  This variable is
>     ' used in another module sheet.
>     current_form = Me.Name
>     ' Check to see if the combo box is null.
>     If Me.cboPayableTerm = Null Then
>         MsgBox "'Payable\Receivable' field must not be left blank"
>         Exit Sub
>     End If
>     ' Open the following report
>     DoCmd.OpenReport "rpt-LEASE RENTAL RECORD/INVOICE", acViewPreview
> End Sub

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

- Show quoted text -

Quote:
> *********************

> By the way, I have also tried the following in place of the second line of
> code, but all to no avail:

> 1)  If Forms(current_form).[cboPayable_Receivable] = Null then
> 2)  If Me.cboPayable_Receivable.Value = Null Then
> 3)  If Me.[cboPayable_Receivable].Value = Null Then
> --



Mon, 22 Jul 2002 03:00:00 GMT  
 Strange Behavior
As other replies indicated, IsNull() is the solution.

For further info, see:
        Common Errors with Null
at:
        http://www.wa.apana.org.au/~abrowne/casu-12.html

Quote:

> Greetings,
>         I have a dilemma in respect to a combo box on a form.  I am attempting to
> check a certain combo box ("cboPayableTerm") to see if it's equal to null.
> If it is, then I want to display a message box and then exit the
> subroutine.  The following code, however, doesn't seem to work.
>         I have stepped through the code and the combo box seems to be evaluating
> to null alright, but for some strange reason it jumps to the end of the
> "IF" statement and keeps executing the subroutine.  Is there something
> blatantly obvious that I'm doing wrong?  Or does it have anything to do
> with the way I am referencing the control on the form?  Any advice you can
> give is most appreciated.  The code I currently have is listed below.

> Thanks in advance,

> Sherwood Page

> ****************************************************************************
> ********

> Private Sub cmdLeaseInvoice_Sheet_Click()
>     ' Assign the name of the current form to a variable.  This variable is
>     ' used in another module sheet.
>     current_form = Me.Name
>     ' Check to see if the combo box is null.
>     If Me.cboPayableTerm = Null Then
>         MsgBox "'Payable\Receivable' field must not be left blank"
>         Exit Sub
>     End If
>     ' Open the following report
>     DoCmd.OpenReport "rpt-LEASE RENTAL RECORD/INVOICE", acViewPreview
> End Sub

> ****************************************************************************
> *********************

> By the way, I have also tried the following in place of the second line of
> code, but all to no avail:

> 1)  If Forms(current_form).[cboPayable_Receivable] = Null then
> 2)  If Me.cboPayable_Receivable.Value = Null Then
> 3)  If Me.[cboPayable_Receivable].Value = Null Then
> --

--
Perth, Western Australia
Tips for MS Access users at:
        http://www.wa.apana.org.au/~abrowne/


Tue, 23 Jul 2002 03:00:00 GMT  
 Strange Behavior
Thanks!

Sherwood



Quote:
> You need to make the following alteration:

> If IsNull(Me!cboPayableTerm) Then

> There are two alterations. Firstly, null never equals null, so you need
to
> use IsnUll, which returns true/false. Secondly, you should use the bang
> operator for controls, and the dot for object properties.
> --

> HTH

> Jon



> > Greetings,
> > I have a dilemma in respect to a combo box on a form.  I am attempting
to
> > check a certain combo box ("cboPayableTerm") to see if it's equal to
null.
> > If it is, then I want to display a message box and then exit the
> > subroutine.  The following code, however, doesn't seem to work.
> > I have stepped through the code and the combo box seems to be
evaluating
> > to null alright, but for some strange reason it jumps to the end of the
> > "IF" statement and keeps executing the subroutine.  Is there something
> > blatantly obvious that I'm doing wrong?  Or does it have anything to do
> > with the way I am referencing the control on the form?  Any advice you
can
> > give is most appreciated.  The code I currently have is listed below.

> > Thanks in advance,

> > Sherwood Page

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

- Show quoted text -

Quote:
> > ********

> > Private Sub cmdLeaseInvoice_Sheet_Click()
> >     ' Assign the name of the current form to a variable.  This variable
is
> >     ' used in another module sheet.
> >     current_form = Me.Name
> >     ' Check to see if the combo box is null.
> >     If Me.cboPayableTerm = Null Then
> >         MsgBox "'Payable\Receivable' field must not be left blank"
> >         Exit Sub
> >     End If
> >     ' Open the following report
> >     DoCmd.OpenReport "rpt-LEASE RENTAL RECORD/INVOICE", acViewPreview
> > End Sub

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

- Show quoted text -

Quote:
> > *********************

> > By the way, I have also tried the following in place of the second line
of
> > code, but all to no avail:

> > 1)  If Forms(current_form).[cboPayable_Receivable] = Null then
> > 2)  If Me.cboPayable_Receivable.Value = Null Then
> > 3)  If Me.[cboPayable_Receivable].Value = Null Then
> > --



Tue, 23 Jul 2002 03:00:00 GMT  
 Strange Behavior
Thanks so much.  That worked!

Sherwood



Quote:
> Does this work:

>    If IsNull(Me.cboPayableTerm) Then
>        '...

> ?
> --

> Dirk Goldgar
> (remove NOSPAM from reply address)



> > Greetings,
> > I have a dilemma in respect to a combo box on a form.  I am attempting
to
> > check a certain combo box ("cboPayableTerm") to see if it's equal to
null.
> > If it is, then I want to display a message box and then exit the
> > subroutine.  The following code, however, doesn't seem to work.
> > I have stepped through the code and the combo box seems to be
evaluating
> > to null alright, but for some strange reason it jumps to the end of the
> > "IF" statement and keeps executing the subroutine.  Is there something
> > blatantly obvious that I'm doing wrong?  Or does it have anything to do
> > with the way I am referencing the control on the form?  Any advice you
can
> > give is most appreciated.  The code I currently have is listed below.

> > Thanks in advance,

> > Sherwood Page

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

- Show quoted text -

Quote:
> > ********

> > Private Sub cmdLeaseInvoice_Sheet_Click()
> >     ' Assign the name of the current form to a variable.  This variable
is
> >     ' used in another module sheet.
> >     current_form = Me.Name
> >     ' Check to see if the combo box is null.
> >     If Me.cboPayableTerm = Null Then
> >         MsgBox "'Payable\Receivable' field must not be left blank"
> >         Exit Sub
> >     End If
> >     ' Open the following report
> >     DoCmd.OpenReport "rpt-LEASE RENTAL RECORD/INVOICE", acViewPreview
> > End Sub

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

- Show quoted text -

Quote:
> > *********************

> > By the way, I have also tried the following in place of the second line
of
> > code, but all to no avail:

> > 1)  If Forms(current_form).[cboPayable_Receivable] = Null then
> > 2)  If Me.cboPayable_Receivable.Value = Null Then
> > 3)  If Me.[cboPayable_Receivable].Value = Null Then
> > --



Tue, 23 Jul 2002 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. MoveFirst, MoveLast strange behavior

2. word mail merge strange behavior

3. Strange behavior with INT function

4. strange behavior

5. Strange behavior in Add-Ins

6. Strange Behavior with queries in code

7. V7 Strange behavior after text import.

8. Access 2.0-Strange behavior when using arrays and UPDATE command

9. DT Picker strange behavior

10. strange behavior with IncludeRecurrences property

11. VBA Strange behavior on Terminal Server

12. Custom Inbox handler - strange behavior

 

 
Powered by phpBB® Forum Software