Full Version: Checkbox problem again.....
UtterAccess Forums > Microsoft® Access > Access Forms
Ok, I have a form that when you click the checkbox it opens another form and when you close the second form, it un-enables the chekbox (so you can't go back to the second form again). I put the code in the AfterUpdate event. That part works great!
ut, if the user goes to the second form and changes their mind about adding a record, I have the code to delete the record and change the checkbox back to 0 (not checked). But because of the AfterUpdate event it un-enables the checkbox, I want it to go back to being enabled.
Can I do that? Is there a cancel event?
form 2 OnOpen clears a switch.

"delete" sets the switch.
In the Onclose of the second form check the switch. If it's not set then disable the checkbox.
Well, the solution probably depends on the specifics of what you're doing. You can cancel an event if you use the BeforeUpdate event and set the Cancel argument to a non-zero (i.e. True) value. There is not a Cancel event per se.
That you may need to do is have code in the Unload event of the second form. This code would detect if there had been any changes and if so either enable or unenable the check box as appropriate. If this second form is bound to a table or updateable query, then you could add the code to disable the checkbox in the form's AfterUpdate event. If the user doesn't save anything to the table, then this event will never fire and thus the check box will never be unenabled.
If that doesn't work, can you please post some more specifics. Namely, is the checkbox on the original form bound/unbound. Is the second form bound/unbound. Does the second form edit data in the same table/query as the first form, etc.
HTH frown.gif
I've attached my db so you can take a look. Click the IDX the first check box and it will put you to the second form. Click some boxes and then click cancel (the user changes their mind). It opens the original form but becuase in the afterupdate event it puts the checkbox to un-enabled.
Thanks, I really appreciate it!
Sorry, can't read it or convert it b/c I don't have sufficient permissions. Can you post a version with no security settings? Thanks!
Ok, sorry....try this....
Hate to be the bearer of bad news, but still have the same security issue :(
You might create a new blank DB and then just copy the pertinent objects into it. Hopefully that way this DB won't have any security settings set, though I'm not the security expert. You could also post the MDW file, though I'd rather much prefer to just have a DB with no security settings frown.gif
I'm not a security exper either....I tried importing the objects when I sent it. This time I used my user account rather than the administrator account. Hope this works.
Alas, still no joy in reading the DB. The good news? I was able to import the objects into a new database of my own creation--don't ask me to explain, but it works! frown.gif
kay, so I'm not 100% sure of what's going on since I didn't write the DB, but let's see if the following is what you want or not.
In the frmAddUserSubform, for the chkIDX_AfterUpdate() sub, get rid of that sub or comment all the lines out for now.
In the frmIDXSubform, for the sub cmdClose_Click() let's try this
Private Sub cmdClose_Click()
On Error GoTo Err_cmdClose_Click
If Forms("frmAddUser").frmAddUserSubform.Form.chkIDX.Value Then
Forms("frmAddUser").frmAddUserSubform.Form.chkIDX.Enabled = False
End If
Exit Sub
MsgBox Err.Description
Resume Exit_cmdClose_Click

End Sub
Obviously, the frmAddUser form must be open for this sub to operate properly. Let me know if this is what you had in mind or not and we'll go from there! frown.gif
Thanks for your help! I got it. I left the AfterUpdate event alone but on the cmdCancel_Click I put to change the chkIDX to 0 and then go back and enable the control.
Thanks for spending the time!
No problem--happy to hear it worked out! frown.gif
I in need of a checkbox "Done" that once it is checked it is somehow disable/can't be check anymore.
This is my coding:
If Me!Done.AfterUpdate = True Then
Me!Done.Enabled = False
MsgBox ("You have just checked")
Me!Done.Enabled = True
MsgBox ("Not checked")
End If

Oneed a checkbox that once checked it is somehow disable.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.