Re: Checkbox in form detail section not updating changes



PW wrote:

On Mon, 23 Nov 2009 23:23:45 -0800, Salad <oil@xxxxxxxxxxx> wrote:


PW wrote:


On Mon, 23 Nov 2009 17:59:30 -0800, Salad <oil@xxxxxxxxxxx> 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

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


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
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.
.



Relevant Pages