Check Box help

empyrean

Registered User.
Local time
Today, 01:53
Joined
Oct 20, 2009
Messages
17
Helloo

I would like to use check box in my form and when you click i need one command to happen and if you dont click it i need another command to happen. i tried using checkbox.value but i am getting error saying this option is not valid. please help me with right syntax.

thankyou
 
What code are you using and what event are you using it on? Both of those are important to answer before we can assist.


welcometoawf.png
 
Try this in the after update event handler:

If Name_Of_Control.Value = True Then
command1
Else
command2
End if
I hope this helps you?
Felix
 
This is what i tried. i am getting error Method or data member not found.

If Me.Checkbox.Value = True Then
DoCmd.OpenReport xxxxxxxx

Else
DoCmd.OpenReport yyyyyyyy
End If
 
This is what i tried. i am getting error Method or data member not found.

If Me.Checkbox.Value = True Then
DoCmd.OpenReport xxxxxxxx

Else
DoCmd.OpenReport yyyyyyyy
End If

Okay, you got ½ of it. The other half is WHICH EVENT IS THIS CODE ON? :) Please provide that. And, is your checkbox really named Checkbox?

How about the REAL code, not just yyyyy or xxxx but exactly what you are using.
 
Replace me.checkbox.value = True Then for

Form_NameOfForm.checkboxname.value = True Then for
 
Replace me.checkbox.value = True Then for

Form_NameOfForm.checkboxname.value = True Then for

Sorry ffleitas, but that is actually a BAD, BAD idea. I don't know if you knew it or not but using that syntax for a form can have unintended consequences when using it. If the form is not open, it will open but HIDDEN and then you can run into other issues due to that.

If the code is ON this form you should use the ME keyword to refer to itself as that eliminates the need to utilize the forms collection, which would normally be used like: Forms!NameOfForm.CheckboxName etc.
 
sorry i am new to access programming and learning now.. i have access form. i created a checkbox on it if user clicks the check box and i need one command to execute which opens one report and if he didnot do anything i wanted to open another report.

here is my actual code


If Me.CheckPed.Value = True Then
DoCmd.OpenReport "rptPer_Refine", acViewPreview, , str, acWindowNormal

Else
DoCmd.OpenReport "rptPer", acViewPreview, , str, acWindowNormal
End If
 
Thanks Bob, you are right. Sorry for the confusion empyrean.
 
so bob, how to tackle this?

i dont have me.checkped.value coming up and even i entered its giving error Method or data member not found.
 
so bob, how to tackle this?

i dont have me.checkped.value coming up and even i entered its giving error Method or data member not found.

Again (I hate to sound like a broken record but...) WHICH EVENT IS THIS ON?
 
sorry i am unable to tell u and i couldnot get about what you are asking.. can you frame it another way? i believe the event is click. after clicking the check box and when user clicks generate report this event should happen like checking whether check box is marked or not, if marked open this report or else open another report.

i apologize for lack of terminology.
 
sorry i am unable to tell u and i couldnot get about what you are asking.. can you frame it another way? i believe the event is click. after clicking the check box and when user clicks generate report this event should happen like checking whether check box is marked or not, if marked open this report or else open another report.

i apologize for lack of terminology.
Okay, the code should be in the checkbox's AFTER UPDATE event. Here's how you would do it and I took out the str part of your code as there is nowhere I can see where you set it and that can cause you problems if you aren't setting it.

chk01.png



chk02.png



chk03.png
 
Hi Bob, can you help me with a MS Word mail merge problem I am having?
Felix
 
Hi Bob, can you help me with a MS Word mail merge problem I am having?
Felix

Have you posted a thread? It should be in a different thread (and I hate Word mail merge by the way, so it might have to be someone else).
 
ok i got wht you are asking... i am sending my code... i am really sorry about the confusion

Private Sub btnRefine_Click()
Dim i As Int
Dim strTemp As String
Dim strFil As String
Dim strM As String
Dim str As String

strM = Me.txtMoiLevel.Value
str = Me.hInpChk.Value
strFil = "ExptlNber IN ('" & Me.txtHyb & "','" & Me.txtSur & "') OR " & _
"(Sur = '" & Me.txtSur & _
"' AND ComN IN (" & str & ")" & _
" AND Moi Between -" & strM & " And " & strM & ")"

If Me.lstChk.ItemsSelected.Count > 0 Then
strTemp = "("
For i = 0 To Me.lstChk.ListCount - 1
If Not lstChk.Selected(i) Then
strTemp = strTemp & "'" & Me.lstChck.Column(0, i) & "',"
End If

Next i
strFil = strFil & " AND ComN IN " & Left(strTemp, Len(strTemp) - 1) & ")"
End If

If Me.CheckPed.ControlType = vbChecked Then
DoCmd.OpenReport "rptPer_Refine", acViewPreview, , strFil, acWindowNormal

Else
DoCmd.OpenReport "rptPerf", acViewPreview, , strFil, acWindowNormal
End If

DoCmd.Maximize
DoCmd.Close acForm, Me.Name
End Sub
 

Users who are viewing this thread

Back
Top Bottom