Customize Value for Check Box

J

Jaybird

I can't seem to locate the earlier answers to this sort of question...
I've got a table that is to be exported as a .dbf file. It is for invoicing
information. It has a number of specific requirements in order to be
uploaded into the corporate system. One is that for credit memos, the value
for [CRMEM] must be 0, and for regular invoices, the value for [CRMEM] must
be 1. I've gotten this to work just fine with this code:

If Me.txtTtlChrgs < 0 Then
Forms.frmInvoice.sbfHDRPLAT.Form.CRMEM = 0
End If
If Me.txtTtlChrgs > 0 Then
Forms.frmInvoice.sbfHDRPLAT.Form.CRMEM = 1
End If

The problem is that the checkbox on my form shows check marks for regular
invoices and is blank for credit memos. I would like the exact opposite to
occur. I can, of course, rename my label to indicate which is which but I
was trying to tell Access what to do in case of a credit memo (mark the box
as checked/ leave black if regular invoice). I discovered that I don't know
how to do this. Can anybody help?
 
C

Cheese_whiz

Hi Jaybird,

If you use an option group, you will be able to set the values to be stored
in the record source to the numbers you choose.

Off topic: In the 'If/Then" statements you included in your post, you have
NOT covered the case where txtTotalChrgs = 0. Is that a problem?

CW
 
K

Klatuu

How you approach this depends on which is the control bound to the field in
the dbf table. To provide an answer, we need to know that. Also, the logic
as written ignores 0 values. It may be that there is no possibility of a 0
value, but I wouldn't depend on that. What will happen in this case if
Me.txtTtlChrgs = 0, Forms.frmInvoice.sbfHDRPLAT.Form.CRMEM will be
either Null or what ever value was already there. You should include 0 in
one side of the logic. Usually, it would be the positive side. Try it this
way:

If Me.txtTtlChrgs < 0 Then
Forms.frmInvoice.sbfHDRPLAT.Form.CRMEM = 0
Else
Forms.frmInvoice.sbfHDRPLAT.Form.CRMEM = 1
End If
 
J

Jaybird

CW, Thanks for the response! It's a work in progress... I don't know if
the zero value is a problem or not. I'll change my code, just in case.
Thanks for the idea about the option group. I guess I've been reaching
toward that step all along, not knowing if it was there or not. Thanks for
turning on the light!
--
Why are you asking me? I dont know what Im doing!

Jaybird


Cheese_whiz said:
Hi Jaybird,

If you use an option group, you will be able to set the values to be stored
in the record source to the numbers you choose.

Off topic: In the 'If/Then" statements you included in your post, you have
NOT covered the case where txtTotalChrgs = 0. Is that a problem?

CW

Jaybird said:
I can't seem to locate the earlier answers to this sort of question...
I've got a table that is to be exported as a .dbf file. It is for invoicing
information. It has a number of specific requirements in order to be
uploaded into the corporate system. One is that for credit memos, the value
for [CRMEM] must be 0, and for regular invoices, the value for [CRMEM] must
be 1. I've gotten this to work just fine with this code:

If Me.txtTtlChrgs < 0 Then
Forms.frmInvoice.sbfHDRPLAT.Form.CRMEM = 0
End If
If Me.txtTtlChrgs > 0 Then
Forms.frmInvoice.sbfHDRPLAT.Form.CRMEM = 1
End If

The problem is that the checkbox on my form shows check marks for regular
invoices and is blank for credit memos. I would like the exact opposite to
occur. I can, of course, rename my label to indicate which is which but I
was trying to tell Access what to do in case of a credit memo (mark the box
as checked/ leave black if regular invoice). I discovered that I don't know
how to do this. Can anybody help?
 
J

Jaybird

Dave,

CRMEM is the control bound to the table. I've got this part working, at
least. I find myself getting confused as to how to change the way the data
appears on the form versus how to change the actual values of the data. CW
says I might try an option group. The idea is interesting to me. However,
I'm interested in your response as well. How WOULD you change the behavior
of the checkbox on the form while leaving the field data as it is?
 
J

Jaybird

Sorry. I forgot to mention that the control on the form is called chkCRMEM.
--
Why are you asking me? I dont know what Im doing!

Jaybird


Klatuu said:
How you approach this depends on which is the control bound to the field in
the dbf table. To provide an answer, we need to know that. Also, the logic
as written ignores 0 values. It may be that there is no possibility of a 0
value, but I wouldn't depend on that. What will happen in this case if
Me.txtTtlChrgs = 0, Forms.frmInvoice.sbfHDRPLAT.Form.CRMEM will be
either Null or what ever value was already there. You should include 0 in
one side of the logic. Usually, it would be the positive side. Try it this
way:

If Me.txtTtlChrgs < 0 Then
Forms.frmInvoice.sbfHDRPLAT.Form.CRMEM = 0
Else
Forms.frmInvoice.sbfHDRPLAT.Form.CRMEM = 1
End If


--
Dave Hargis, Microsoft Access MVP


Jaybird said:
I can't seem to locate the earlier answers to this sort of question...
I've got a table that is to be exported as a .dbf file. It is for invoicing
information. It has a number of specific requirements in order to be
uploaded into the corporate system. One is that for credit memos, the value
for [CRMEM] must be 0, and for regular invoices, the value for [CRMEM] must
be 1. I've gotten this to work just fine with this code:

If Me.txtTtlChrgs < 0 Then
Forms.frmInvoice.sbfHDRPLAT.Form.CRMEM = 0
End If
If Me.txtTtlChrgs > 0 Then
Forms.frmInvoice.sbfHDRPLAT.Form.CRMEM = 1
End If

The problem is that the checkbox on my form shows check marks for regular
invoices and is blank for credit memos. I would like the exact opposite to
occur. I can, of course, rename my label to indicate which is which but I
was trying to tell Access what to do in case of a credit memo (mark the box
as checked/ leave black if regular invoice). I discovered that I don't know
how to do this. Can anybody help?
 
K

Klatuu

Still a little lost.
I understand is the bound control and should be 0 for Credit Memos and 1 for
regular invoices.

What is the check box? And what part does Me.txtTtlChrgs play in this?
--
Dave Hargis, Microsoft Access MVP


Jaybird said:
Sorry. I forgot to mention that the control on the form is called chkCRMEM.
--
Why are you asking me? I dont know what Im doing!

Jaybird


Klatuu said:
How you approach this depends on which is the control bound to the field in
the dbf table. To provide an answer, we need to know that. Also, the logic
as written ignores 0 values. It may be that there is no possibility of a 0
value, but I wouldn't depend on that. What will happen in this case if
Me.txtTtlChrgs = 0, Forms.frmInvoice.sbfHDRPLAT.Form.CRMEM will be
either Null or what ever value was already there. You should include 0 in
one side of the logic. Usually, it would be the positive side. Try it this
way:

If Me.txtTtlChrgs < 0 Then
Forms.frmInvoice.sbfHDRPLAT.Form.CRMEM = 0
Else
Forms.frmInvoice.sbfHDRPLAT.Form.CRMEM = 1
End If


--
Dave Hargis, Microsoft Access MVP


Jaybird said:
I can't seem to locate the earlier answers to this sort of question...
I've got a table that is to be exported as a .dbf file. It is for invoicing
information. It has a number of specific requirements in order to be
uploaded into the corporate system. One is that for credit memos, the value
for [CRMEM] must be 0, and for regular invoices, the value for [CRMEM] must
be 1. I've gotten this to work just fine with this code:

If Me.txtTtlChrgs < 0 Then
Forms.frmInvoice.sbfHDRPLAT.Form.CRMEM = 0
End If
If Me.txtTtlChrgs > 0 Then
Forms.frmInvoice.sbfHDRPLAT.Form.CRMEM = 1
End If

The problem is that the checkbox on my form shows check marks for regular
invoices and is blank for credit memos. I would like the exact opposite to
occur. I can, of course, rename my label to indicate which is which but I
was trying to tell Access what to do in case of a credit memo (mark the box
as checked/ leave black if regular invoice). I discovered that I don't know
how to do this. Can anybody help?
 
J

Jaybird

The control for the checkbox on the form is chkCRMEM. The bound control is
CRMEM. txtTtlChrgs is the sum of charges for the invoice. When it is
negative, I want the checkbox to appear as checked while the underlying value
is still 1. When txtTtlChrgs is positive (or zero as you point out) I want
the checkbox to appear as blank while the underlying value is 0. The reason
for this is that it seems more intuitive to have the checkbox checked if the
Invoice is a credit memo than it would be otherwise. I am forced to use the
value of 1 as indicating an invoice, and a zero to indicate a credit memo
(per our corporate system), but Access reads these values opposite of the way
I would like. A zero value (credit memo) causes a checkbox to appear as
blank (not what I want), while a value of 1 causes the checkbox to appear as
checked (also not what I want). There are easy ways to get around this (e.g.
change my checkbox label) but it made me wonder how I could do this.
 
K

Klatuu

Okay
txtTtlChrgs is the Total Charges for the current record
Forms.frmInvoice.sbfHDRPLAT.Form.CRMEM Is the bound control to the field
CRMEM in the table. It should be 0 for Credit Memo and 1 for regular invoice
chkCRMEM is an unbound check box that shows whether CREMEM is 0 or 1.

I would assume this code is in the After Update event of txtTtlChrgs:

If Me.txtTtlChrgs < 0 Then
Forms.frmInvoice.sbfHDRPLAT.Form.CRMEM = 0
Else
Forms.frmInvoice.sbfHDRPLAT.Form.CRMEM = 1
End If

If all my assumptions are correct, make this the Control Source for chkCRMEM:

= txtTtlCharges = 0
 
J

Jaybird

Ah. Now we're getting somewhere... I should not bind my checkbox to
chkCRMEM at all, right? I should give it a conditional value based on
txtTtlCharges. I feel really silly, now. I've got just such a conditional
statement on an unbound label that says, "This is an Invoice!" in red
letters. I swear, I really can't think straight sometimes. Thanks!
 

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