Full Version: check box not working
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
iftikhar_k
Hi there guys,

I have a form and I want to add a check box in it, to give the user an option to open a different form.
The user enters the order number in a text box. My code runs after the update event of the text box. I have added this code which is not working.

Private Sub txtOrder_AfterUpdate()

code
code
code
New code
if Me.chkbox Then
DoCmd.OpenForm "MY_New_Form"
exit sub
end if
.
.
End Sub
The new form opens, no matter if the check box is checked or not. I've no idea why its doing that.
Anyone have any ideas.
Thanks for your time and advice in advance.
malcolmd83
Have you tried:

If Me.chkbox = True Then
freakazeud
Me.chkbox.Value = True Then

should do the same thing like malcom suggested. You have to check for the value of the checkbox and not for the checkbox itself.
Good luck.
iftikhar_k
I had tried If Me.chkbox = True then

but it didn't work.

I just tried If Me.chkbox.Value = True then
but it gives me the same result, it opens the form no matter if the box is check or not.

I would've changed the checkbox to a command button, but I need the AfterUpdate event code to run before I can open the form. So I need a way to know what the user wants to do before I run the UpdateEvent.

Thank you very much for your time and advice.

How are you doing Oliver frown.gif

Edited by: iftikhar_k on Fri Apr 8 10:43:32 EDT 2005.
freakazeud
Is this an unbound checkbox?
Try:
Forms!FormName!chkbox.value = True
Or
[Forms]![FormName].chkbox.value = True
Or
Me.FormName.chkbox.value = True

Play around with it.
iftikhar_k
I tried all the options, but no luck, I'm totally shocked, its not like I've not used check boxes before. I don't know this one is soo stubborn, I must be doing some logical error somewhere. I deleted the check box made a new one, but that one is behaving the same way.
I guess I'll just find another way to do it and forget the check box idea.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.