Checkboxes on reports

  • Thread starter Thread starter Peter Afonin
  • Start date Start date
P

Peter Afonin

Hello,

I'm using an Access project. In the report I have many checkboxes populated
from the database. Some of them checked, some not. Everything looks right.
However, when I try to get checkboxes values in code - I always get True, no
matter whether this checkbox is checked or not. Why is this? How can I get
the correct values? I don't have this problem with any other control, only
checkboxes.

I would appreciate your help.

Thank you,
 
What is the line of code your using? Are you sure you are not just checking
the first record?

HTH
Martin J
 
Thank you,

Yes, I'm sure. The code is very simple, like if I have a checkboxes chk1 and
chk2, I'm just declaring couple of boolean variables

Dim a as Boolean
Dim b as Boolean

a=Me.chk1
b=Me.chk2

put a breakpoint there, open the report and watch all values of these
checkboxes.

The same way I was checking the textboxes, and they always were showing all
values correctly.

Thanks,

Peter
 
So from what line of code to what line of code are you losing the value? Are
you calling a function and passing the values? if so does the function still
have the correct value? Are you trying to change some checkbox values in a
function? if so you have to pass not by value but by address. If you could
post the code or whatever that is giving you the problem it would be a lot
easier to diagnose.

HTH
Martin J
 
Martin,

All I do - I put this code in the reports Detail_Format event, put a
breakpoint then look at all values by pressing F11.

While all textbox values are correct, the checkbox values are always True.


Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
On Error GoTo errHandler

Dim b As Boolean
Dim a As Boolean
Dim s As String

b = Me.chk1
a = Me.ckh2
s = Me.txtTest


GetOut:
Exit Sub
errHandler:
MsgBox "Error No.:" & CStr(Err.NUMBER) & vbCrLf & Err.Description & vbCrLf
& Err.Source, vbCritical
Resume GetOut

End Sub

Thank you,

Peter
 
Put a watch(right click-add watch) in for me.chk1 when i do it it usaully is
a=me![chk1]. There you can see the values. Make sure the watch screen is
showing.

HTH
Martin J
 
Let me be clearer the syntax i use when I have trouble is me![chk1].
Me.whatever is usaully a property not a value. What you want to put in your
watch is me.chk1.

HTH
Martin J

Martin J said:
Put a watch(right click-add watch) in for me.chk1 when i do it it usaully is
a=me![chk1]. There you can see the values. Make sure the watch screen is
showing.

HTH
Martin J

Peter Afonin said:
Martin,

All I do - I put this code in the reports Detail_Format event, put a
breakpoint then look at all values by pressing F11.

While all textbox values are correct, the checkbox values are always True.


Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
On Error GoTo errHandler

Dim b As Boolean
Dim a As Boolean
Dim s As String

b = Me.chk1
a = Me.ckh2
s = Me.txtTest


GetOut:
Exit Sub
errHandler:
MsgBox "Error No.:" & CStr(Err.NUMBER) & vbCrLf & Err.Description & vbCrLf
& Err.Source, vbCritical
Resume GetOut

End Sub

Thank you,

Peter
 
Hi Martin,

I did this, and they all were True.

However, it seems that I've found the problem. I don't have a clue yet why
it works like this, but it does.

The user checks the corresponding checkboxes on the form. If he checks the
box, then unchecks it, everything works as it should - the value is False.
If, however, this checkbox was never touched (i.e. it looks grey) - tha
value is True.

I need to check an underlying table. My guess is that unless I initialize
the checkbox on the form, it inserts probably the Null value into the table,
which is probably producing the value True on the report.

I don't see another explanation, but I probably should check the table
first.

Thank you very much for your help!

Peter

Martin J said:
Put a watch(right click-add watch) in for me.chk1 when i do it it usaully is
a=me![chk1]. There you can see the values. Make sure the watch screen is
showing.

HTH
Martin J

Peter Afonin said:
Martin,

All I do - I put this code in the reports Detail_Format event, put a
breakpoint then look at all values by pressing F11.

While all textbox values are correct, the checkbox values are always True.


Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
On Error GoTo errHandler

Dim b As Boolean
Dim a As Boolean
Dim s As String

b = Me.chk1
a = Me.ckh2
s = Me.txtTest


GetOut:
Exit Sub
errHandler:
MsgBox "Error No.:" & CStr(Err.NUMBER) & vbCrLf & Err.Description & vbCrLf
& Err.Source, vbCritical
Resume GetOut

End Sub

Thank you,

Peter

value?
Are chk1
and showing
all can
I
 
Are you using ADP 2002 on WinXP with SP2?

I had the same kind of problem with ADP 2002 on WinXP after the installation
of SP2. Not only were the values from checkboxes wrong the first time I
clicked on them but the values for other columns were corrupted as well.
This was particularly visible after the use of call to
Recordset.RecordsetClone but was not limited to this.

Before SP2 and after replacing A2002 with A2003, no problem at all with
checkboxes and bit values.

S. L.

Peter Afonin said:
Hi Martin,

I did this, and they all were True.

However, it seems that I've found the problem. I don't have a clue yet why
it works like this, but it does.

The user checks the corresponding checkboxes on the form. If he checks the
box, then unchecks it, everything works as it should - the value is False.
If, however, this checkbox was never touched (i.e. it looks grey) - tha
value is True.

I need to check an underlying table. My guess is that unless I initialize
the checkbox on the form, it inserts probably the Null value into the
table,
which is probably producing the value True on the report.

I don't see another explanation, but I probably should check the table
first.

Thank you very much for your help!

Peter

Martin J said:
Put a watch(right click-add watch) in for me.chk1 when i do it it usaully is
a=me![chk1]. There you can see the values. Make sure the watch screen is
showing.

HTH
Martin J

Peter Afonin said:
Martin,

All I do - I put this code in the reports Detail_Format event, put a
breakpoint then look at all values by pressing F11.

While all textbox values are correct, the checkbox values are always True.


Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
On Error GoTo errHandler

Dim b As Boolean
Dim a As Boolean
Dim s As String

b = Me.chk1
a = Me.ckh2
s = Me.txtTest


GetOut:
Exit Sub
errHandler:
MsgBox "Error No.:" & CStr(Err.NUMBER) & vbCrLf & Err.Description & vbCrLf
& Err.Source, vbCritical
Resume GetOut

End Sub

Thank you,

Peter

So from what line of code to what line of code are you losing the value?
Are
you calling a function and passing the values? if so does the
function
still
have the correct value? Are you trying to change some checkbox values in a
function? if so you have to pass not by value but by address. If you could
post the code or whatever that is giving you the problem it would be
a lot
easier to diagnose.

HTH
Martin J

:

Thank you,

Yes, I'm sure. The code is very simple, like if I have a checkboxes chk1
and
chk2, I'm just declaring couple of boolean variables

Dim a as Boolean
Dim b as Boolean

a=Me.chk1
b=Me.chk2

put a breakpoint there, open the report and watch all values of these
checkboxes.

The same way I was checking the textboxes, and they always were showing
all
values correctly.

Thanks,

Peter

What is the line of code your using? Are you sure you are not
just
checking
the first record?

HTH
Martin J

:

Hello,

I'm using an Access project. In the report I have many checkboxes
populated
from the database. Some of them checked, some not. Everything looks
right.
However, when I try to get checkboxes values in code - I always get
True, no
matter whether this checkbox is checked or not. Why is this?
How can
I
get
the correct values? I don't have this problem with any other
control,
only
checkboxes.

I would appreciate your help.

Thank you,
 
Hi,

No, I'm using ADP 2003 on Windows Server 2003, so there is no SP2 here.

I guess this is by design, I've just forgot about it.

Peter

Sylvain Lafontaine said:
Are you using ADP 2002 on WinXP with SP2?

I had the same kind of problem with ADP 2002 on WinXP after the installation
of SP2. Not only were the values from checkboxes wrong the first time I
clicked on them but the values for other columns were corrupted as well.
This was particularly visible after the use of call to
Recordset.RecordsetClone but was not limited to this.

Before SP2 and after replacing A2002 with A2003, no problem at all with
checkboxes and bit values.

S. L.

Peter Afonin said:
Hi Martin,

I did this, and they all were True.

However, it seems that I've found the problem. I don't have a clue yet why
it works like this, but it does.

The user checks the corresponding checkboxes on the form. If he checks the
box, then unchecks it, everything works as it should - the value is False.
If, however, this checkbox was never touched (i.e. it looks grey) - tha
value is True.

I need to check an underlying table. My guess is that unless I initialize
the checkbox on the form, it inserts probably the Null value into the
table,
which is probably producing the value True on the report.

I don't see another explanation, but I probably should check the table
first.

Thank you very much for your help!

Peter

Martin J said:
Put a watch(right click-add watch) in for me.chk1 when i do it it
usaully
is
a=me![chk1]. There you can see the values. Make sure the watch screen is
showing.

HTH
Martin J

:

Martin,

All I do - I put this code in the reports Detail_Format event, put a
breakpoint then look at all values by pressing F11.

While all textbox values are correct, the checkbox values are always True.


Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
On Error GoTo errHandler

Dim b As Boolean
Dim a As Boolean
Dim s As String

b = Me.chk1
a = Me.ckh2
s = Me.txtTest


GetOut:
Exit Sub
errHandler:
MsgBox "Error No.:" & CStr(Err.NUMBER) & vbCrLf & Err.Description & vbCrLf
& Err.Source, vbCritical
Resume GetOut

End Sub

Thank you,

Peter

So from what line of code to what line of code are you losing the value?
Are
you calling a function and passing the values? if so does the
function
still
have the correct value? Are you trying to change some checkbox
values
in a
function? if so you have to pass not by value but by address. If
you
could
post the code or whatever that is giving you the problem it would be
a lot
easier to diagnose.

HTH
Martin J

:

Thank you,

Yes, I'm sure. The code is very simple, like if I have a
checkboxes
chk1
and
chk2, I'm just declaring couple of boolean variables

Dim a as Boolean
Dim b as Boolean

a=Me.chk1
b=Me.chk2

put a breakpoint there, open the report and watch all values of these
checkboxes.

The same way I was checking the textboxes, and they always were showing
all
values correctly.

Thanks,

Peter

What is the line of code your using? Are you sure you are not
just
checking
the first record?

HTH
Martin J

:

Hello,

I'm using an Access project. In the report I have many checkboxes
populated
from the database. Some of them checked, some not. Everything looks
right.
However, when I try to get checkboxes values in code - I
always
get
True, no
matter whether this checkbox is checked or not. Why is this?
How can
I
get
the correct values? I don't have this problem with any other
control,
only
checkboxes.

I would appreciate your help.

Thank you,
 
Probably the default value of the checkbox field in the table has not been
set to false. So in fact it returns a value of Null (Grey coloured box). If
the user fiddles around it will set to either true or false. (-1 or 0)
Just set the default value to False and do an update query to set all the
fields that are null to 0 ( false)

Phil

Peter Afonin said:
Hi,

No, I'm using ADP 2003 on Windows Server 2003, so there is no SP2 here.

I guess this is by design, I've just forgot about it.

Peter

Sylvain Lafontaine said:
Are you using ADP 2002 on WinXP with SP2?

I had the same kind of problem with ADP 2002 on WinXP after the installation
of SP2. Not only were the values from checkboxes wrong the first time I
clicked on them but the values for other columns were corrupted as well.
This was particularly visible after the use of call to
Recordset.RecordsetClone but was not limited to this.

Before SP2 and after replacing A2002 with A2003, no problem at all with
checkboxes and bit values.

S. L.

Peter Afonin said:
Hi Martin,

I did this, and they all were True.

However, it seems that I've found the problem. I don't have a clue yet why
it works like this, but it does.

The user checks the corresponding checkboxes on the form. If he checks the
box, then unchecks it, everything works as it should - the value is False.
If, however, this checkbox was never touched (i.e. it looks grey) - tha
value is True.

I need to check an underlying table. My guess is that unless I initialize
the checkbox on the form, it inserts probably the Null value into the
table,
which is probably producing the value True on the report.

I don't see another explanation, but I probably should check the table
first.

Thank you very much for your help!

Peter

Put a watch(right click-add watch) in for me.chk1 when i do it it usaully
is
a=me![chk1]. There you can see the values. Make sure the watch screen is
showing.

HTH
Martin J

:

Martin,

All I do - I put this code in the reports Detail_Format event, put a
breakpoint then look at all values by pressing F11.

While all textbox values are correct, the checkbox values are always
True.


Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
On Error GoTo errHandler

Dim b As Boolean
Dim a As Boolean
Dim s As String

b = Me.chk1
a = Me.ckh2
s = Me.txtTest


GetOut:
Exit Sub
errHandler:
MsgBox "Error No.:" & CStr(Err.NUMBER) & vbCrLf & Err.Description
&
vbCrLf
& Err.Source, vbCritical
Resume GetOut

End Sub

Thank you,

Peter

So from what line of code to what line of code are you losing the
value?
Are
you calling a function and passing the values? if so does the
function
still
have the correct value? Are you trying to change some checkbox values
in a
function? if so you have to pass not by value but by address. If you
could
post the code or whatever that is giving you the problem it would be
a
lot
easier to diagnose.

HTH
Martin J

:

Thank you,

Yes, I'm sure. The code is very simple, like if I have a checkboxes
chk1
and
chk2, I'm just declaring couple of boolean variables

Dim a as Boolean
Dim b as Boolean

a=Me.chk1
b=Me.chk2

put a breakpoint there, open the report and watch all values of
these
checkboxes.

The same way I was checking the textboxes, and they always were
showing
all
values correctly.

Thanks,

Peter

What is the line of code your using? Are you sure you are not
just
checking
the first record?

HTH
Martin J

:

Hello,

I'm using an Access project. In the report I have many
checkboxes
populated
from the database. Some of them checked, some not.
Everything
looks
right.
However, when I try to get checkboxes values in code - I always
get
True, no
matter whether this checkbox is checked or not. Why is this?
How
can
I
get
the correct values? I don't have this problem with any other
control,
only
checkboxes.

I would appreciate your help.

Thank you,
 
Thank you, Phil. Good idea.

Peter

Phil Stanton said:
Probably the default value of the checkbox field in the table has not been
set to false. So in fact it returns a value of Null (Grey coloured box). If
the user fiddles around it will set to either true or false. (-1 or 0)
Just set the default value to False and do an update query to set all the
fields that are null to 0 ( false)

Phil

Peter Afonin said:
Hi,

No, I'm using ADP 2003 on Windows Server 2003, so there is no SP2 here.

I guess this is by design, I've just forgot about it.

Peter

Sylvain Lafontaine said:
Are you using ADP 2002 on WinXP with SP2?

I had the same kind of problem with ADP 2002 on WinXP after the installation
of SP2. Not only were the values from checkboxes wrong the first time I
clicked on them but the values for other columns were corrupted as well.
This was particularly visible after the use of call to
Recordset.RecordsetClone but was not limited to this.

Before SP2 and after replacing A2002 with A2003, no problem at all with
checkboxes and bit values.

S. L.

Hi Martin,

I did this, and they all were True.

However, it seems that I've found the problem. I don't have a clue
yet
why
it works like this, but it does.

The user checks the corresponding checkboxes on the form. If he
checks
the
box, then unchecks it, everything works as it should - the value is False.
If, however, this checkbox was never touched (i.e. it looks grey) - tha
value is True.

I need to check an underlying table. My guess is that unless I initialize
the checkbox on the form, it inserts probably the Null value into the
table,
which is probably producing the value True on the report.

I don't see another explanation, but I probably should check the table
first.

Thank you very much for your help!

Peter

Put a watch(right click-add watch) in for me.chk1 when i do it it usaully
is
a=me![chk1]. There you can see the values. Make sure the watch
screen
is
showing.

HTH
Martin J

:

Martin,

All I do - I put this code in the reports Detail_Format event, put a
breakpoint then look at all values by pressing F11.

While all textbox values are correct, the checkbox values are always
True.


Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
On Error GoTo errHandler

Dim b As Boolean
Dim a As Boolean
Dim s As String

b = Me.chk1
a = Me.ckh2
s = Me.txtTest


GetOut:
Exit Sub
errHandler:
MsgBox "Error No.:" & CStr(Err.NUMBER) & vbCrLf & Err.Description
&
vbCrLf
& Err.Source, vbCritical
Resume GetOut

End Sub

Thank you,

Peter

So from what line of code to what line of code are you losing the
value?
Are
you calling a function and passing the values? if so does the
function
still
have the correct value? Are you trying to change some checkbox values
in a
function? if so you have to pass not by value but by address. If you
could
post the code or whatever that is giving you the problem it
would
be
a
lot
easier to diagnose.

HTH
Martin J

:

Thank you,

Yes, I'm sure. The code is very simple, like if I have a checkboxes
chk1
and
chk2, I'm just declaring couple of boolean variables

Dim a as Boolean
Dim b as Boolean

a=Me.chk1
b=Me.chk2

put a breakpoint there, open the report and watch all values of
these
checkboxes.

The same way I was checking the textboxes, and they always were
showing
all
values correctly.

Thanks,

Peter

What is the line of code your using? Are you sure you are not
just
checking
the first record?

HTH
Martin J

:

Hello,

I'm using an Access project. In the report I have many
checkboxes
populated
from the database. Some of them checked, some not.
Everything
looks
right.
However, when I try to get checkboxes values in code - I always
get
True, no
matter whether this checkbox is checked or not. Why is this?
How
can
I
get
the correct values? I don't have this problem with any other
control,
only
checkboxes.

I would appreciate your help.

Thank you,
 
Back
Top