Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Checkbox in form detail section not updating changes

23 views
Skip to first unread message

PW

unread,
Nov 23, 2009, 6:30:07 PM11/23/09
to
Hi,

I feel like such a newbie! Sorry! But I can not figure out why a
checkbox in the detail section of a form reflects any change made to
it but when I go into debug, it is always set to True when I am trying
to update a table.

I uncheck it in the form but it remains as True. The field in the
table is a Yes/No field. I have tried setting the detail section to
the table itself and also a query.

So what is this braindead developer doing wrong? :-)

Thanks,

-paulw

Salad

unread,
Nov 23, 2009, 8:59:30 PM11/23/09
to

Is it a bound or unbound checkbox? If bound to a table field, is the
field set to true?

What is the default value of the checkbox? For example, you might have
the default set to true and if bound and in a new record it would be true.

Or do you think it is a bound control but isn't but you have the default
set to true?

Maybe delete the control, compact the database, and add the control.

Maybe you have code in the OnCurrent event like
me.checkboxname = True


PW

unread,
Nov 24, 2009, 1:08:59 AM11/24/09
to
On Mon, 23 Nov 2009 17:59:30 -0800, Salad <o...@vinegar.com> wrote:

>PW wrote:
>> Hi,
>>
>> I feel like such a newbie! Sorry! But I can not figure out why a
>> checkbox in the detail section of a form reflects any change made to
>> it but when I go into debug, it is always set to True when I am trying
>> to update a table.
>>
>> I uncheck it in the form but it remains as True. The field in the
>> table is a Yes/No field. I have tried setting the detail section to
>> the table itself and also a query.
>>
>> So what is this braindead developer doing wrong? :-)
>>
>> Thanks,
>>
>> -paulw
>
>Is it a bound or unbound checkbox? If bound to a table field, is the
>field set to true?


Bound, but the field is not set to anythingSet

>
>What is the default value of the checkbox? For example, you might have
>the default set to true and if bound and in a new record it would be true.
>

No default value. I load the "work file" which is what I am reading
to populate a table and is in the detail section as such:

Set rstWorkf = db.OpenRecordset("tblMenuPermWorkf")
Set rstObjPerms = db.OpenRecordset("tblObjectPermissions")

With rstObjPerms
!PermissionYN = rstObjPerms!PermissionYN
End With


>Or do you think it is a bound control but isn't but you have the default
>set to true?
>
>Maybe delete the control, compact the database, and add the control.
>
>Maybe you have code in the OnCurrent event like
> me.checkboxname = True
>

Nope, it is directly from the table:

SELECT tblMenuPermWorkf.Level1Menu, tblMenuPermWorkf.Level2Menu,
tblMenuPermWorkf.Level3Menu, tblMenuPermWorkf.PermissionYN
FROM tblMenuPermWorkf
ORDER BY tblMenuPermWorkf.Level1Menu, tblMenuPermWorkf.Level2Menu,
tblMenuPermWorkf.Level3Menu;


Here is the code for the click event of the save button:

Private Sub PopPermissions()

Dim strFind As String
Dim strObjectName As String
Dim strGroupName As String

Dim rstWorkf As Recordset
Dim rstObjPerms As Recordset

Dim db As Database

Set db = CurrentDb()
'Set rstWorkf = db.OpenRecordset("tblMenuPermWorkf")
Set rstWorkf = db.OpenRecordset("qryMenuPermWorkf")
Set rstObjPerms = db.OpenRecordset("tblObjectPermissions")

strGroupName = Trim(Me.cboGroupNames)

rstWorkf.MoveFirst

Do While Not rstWorkf.EOF

If IsNull(rstWorkf!Level2Menu) Then
strObjectName = Trim(rstWorkf!Level1Menu)
End If

If Not IsNull(rstWorkf!Level2Menu) And IsNull(rstWorkf!Level3Menu)
Then
strObjectName = rstWorkf!Level2Menu
End If

If Not IsNull(rstWorkf!Level3Menu) Then
strObjectName = rstWorkf!Level3Menu
End If

strFind = "[objectname] = '" & strObjectName & "' And
Trim([GroupName]) = '" & strGroupName & "'"

rstObjPerms.FindFirst strFind

If rstObjPerms.NoMatch Then

rstObjPerms.addnew
rstObjPerms!ObjectName = strObjectName
rstObjPerms!GroupName = strGroupName
rstObjPerms!ObjectType = "M"

Else
rstObjPerms.Edit
End If

' HERE is where the checkbox always = True:

rstObjPerms!PermissionYN = rstWorkf!PermissionYN

rstObjPerms.Update

rstWorkf.MoveNext

Loop

-pw

Salad

unread,
Nov 24, 2009, 2:23:45 AM11/24/09
to
PW wrote:

I'd delete the control and start over after compacting it after
deleteing it.

PW

unread,
Nov 24, 2009, 6:46:44 PM11/24/09
to

I did. And I also went back to using the table directly instead of a
query. Still no change. PermissionsYN = True even though the
checkbox is unchecked in the form.

-pw

Salad

unread,
Nov 24, 2009, 7:26:19 PM11/24/09
to
PW wrote:

Where in your code are you updating the recordset from the a control on
the form? I see an update coming from a recordset value but nothing
from a form.

PW

unread,
Nov 24, 2009, 8:05:07 PM11/24/09
to

>Where in your code are you updating the recordset from the a control on
>the form? I see an update coming from a recordset value but nothing
>from a form.

I have the detail section going directly to the table now
(tblMenuPermWorkf). I do not understand why the field still isn't
getting populated in the table. If I uncheck the checkbox, why would
I still have to update the table? I will be gone for a few days but
will check back. Thanks Salad!

Private Sub PopPermissions()

Dim strFind As String
Dim strObjectName As String
Dim strGroupName As String

Dim rstWorkF As Recordset
Dim rstObjPerms As Recordset

Dim db As Database

Set db = CurrentDb()
Set rstWorkF = db.OpenRecordset("tblMenuPermWorkf")
'Set rstWorkF = db.OpenRecordset("qryMenuPermWorkf")


Set rstObjPerms = db.OpenRecordset("tblObjectPermissions")

strGroupName = Trim(Me.cboGroupNames)

rstWorkF.MoveFirst

Do While Not rstWorkF.EOF


' Need to get the proper object to lookup in the permissions table.
' If the Level2Menu is empty, use Level1Menu which means its a main
menu.
' If Level3Menu contains something, us it as it is a "sub-sub" menu.
' If Level2Menu contains something, and Level3Menu is empty, then it's
a submenu:

If IsNull(rstWorkF!Level2Menu) Then
strObjectName = Trim(rstWorkF!Level1Menu)
End If

If Not IsNull(rstWorkF!Level2Menu) And IsNull(rstWorkF!Level3Menu)
Then
strObjectName = rstWorkF!Level2Menu
End If

If Not IsNull(rstWorkF!Level3Menu) Then
strObjectName = rstWorkF!Level3Menu
End If

strFind = "[objectname] = '" & strObjectName & "' And
Trim([GroupName]) = '" & strGroupName & "'"

rstObjPerms.FindFirst strFind

' If no record for the group + object (will this ever happen?), add
it. Otherwise just populate the PermissionYN field:

If rstObjPerms.NoMatch Then

rstObjPerms.addnew
rstObjPerms!ObjectName = strObjectName
rstObjPerms!GroupName = strGroupName
rstObjPerms!ObjectType = "M"

Else
rstObjPerms.Edit
End If

rstObjPerms!PermissionYN = rstWorkF!PermissionYN

rstObjPerms.Update

rstWorkF.MoveNext

Loop


End Sub

0 new messages