Mysterious variable not defined error in Access 2007

H

hedgracer

I have the following code:

Public Function BSS_Payment_chkExchange()
intCount = intCount + 1
strExch = "Exchange" 'OK
strSelect = strSelect & ", Exchange"
If chkGroupBy = -1 Or chkSumQuantity = -1 Or _
chkSumCashAdjusted = -1 Or chkSumUnadjustedGiveUpRevenue = -1
Or _
chkSumDetailDisputed = -1 Or chkSumTotalAmtDue = -1 Then
strGroupBy = strGroupBy & ",Exchange"
End If

If Not IsNull(cboExchange) Then
intTextB = 0
strWhere = strWhere & "AND (" & _
strExch & _
" = '" & _
cboExchange & _
"') "
End If

I am getting a "Variable Not Defined" error message on
chkSumTotalAmtDue when I compile but not on the the other items
starting with chk. These are not variables but check boxes. All are
set up exactly the same in the VBA code. Can someone give me a clue to
what I am possibly missing? Thanks for all help in advance.

Dave

End Function
 
K

Ken Snell

I assume that you're running this function in a form's module? If not, the
function does not have any knowledge of the form's controls (checkboxes) and
can't "see" them.

If you are running this inside a form's module, then check the spelling of
the control on the form.
 
H

hedgracer

I assume that you're running this function in a form's module? If not, the
function does not have any knowledge of the form's controls (checkboxes) and
can't "see" them.

If you are running this inside a form's module, then check the spelling of
the control on the form.

--

        Ken Snellhttp://www.accessmvp.com/KDSnell/









- Show quoted text -

The function is running inside of the form's module and I have checked
the spelling a bunch of times. All of the chk items work except for
this one. This is so bizarre.

Dave
 
J

John W. Vinson

I have the following code:

Public Function BSS_Payment_chkExchange()
intCount = intCount + 1
strExch = "Exchange" 'OK
strSelect = strSelect & ", Exchange"
If chkGroupBy = -1 Or chkSumQuantity = -1 Or _
chkSumCashAdjusted = -1 Or chkSumUnadjustedGiveUpRevenue = -1
Or _
chkSumDetailDisputed = -1 Or chkSumTotalAmtDue = -1 Then
strGroupBy = strGroupBy & ",Exchange"
End If

If Not IsNull(cboExchange) Then
intTextB = 0
strWhere = strWhere & "AND (" & _
strExch & _
" = '" & _
cboExchange & _
"') "
End If

I am getting a "Variable Not Defined" error message on
chkSumTotalAmtDue when I compile but not on the the other items
starting with chk. These are not variables but check boxes. All are
set up exactly the same in the VBA code. Can someone give me a clue to
what I am possibly missing? Thanks for all help in advance.

Dave

End Function

Just to see, try explicitly defining them as controls: instead of
chkSumTotalAmtDue try Me![chkSumTotalAmtDue] and see if that avoids the
error.

You do have Option Explicit set, I hope?
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/Forums/en-US/accessdev/
http://social.answers.microsoft.com/Forums/en-US/addbuz/
and see also http://www.utteraccess.com
 
D

David W. Fenton

Just to see, try explicitly defining them as controls: instead of
chkSumTotalAmtDue try Me![chkSumTotalAmtDue] and see if that
avoids the error.

For what it's worth, I'd say you're writing really bad code unless
you ALWAYS do what John has suggested here.
 
A

a a r o n _ k e m p f

I think that me.chkSumTotalAmtDue is more proper (because it will
barf / not compile) when the control is missing




John W. Vinson said:
Just to see, try explicitly defining them as controls: instead of
chkSumTotalAmtDue   try  Me![chkSumTotalAmtDue]  and see if that
avoids the error.

For what it's worth, I'd say you're writing really bad code unless
you ALWAYS do what John has suggested here.
 

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

Top