Checkbox on Report based on Combo Box on Form

jrs

New member
Local time
Today, 22:46
Joined
Aug 23, 2000
Messages
9
I have a form with a combo box that has three possible values (Text1, Text2 and Text3). On my report, I have three checkboxes (Checkbox1, Checkbox2 and Checkbox3).

If the combo box value is “Text1” then I need Checkbox1 “Checked”.
If the combo box value is “Text2” then I need Checkbox2 “Checked”.
If the combo box value is “Text3” then I need Checkbox3 “Checked”.

Any suggestions?

Thanks in advance for your help.
 
Go the the Detail Section Properties in your report and click on the Code Builder in the On_Format Event. Enter the folowing code (adjust as needed to fit your exact application).

If Me.Box1 = "Text1" Then
Me.Check3 = -1
Me.Check5 = 0
Me.Check6 = 0
ElseIf Me.Box1 = "Text2" Then
Me.Check3 = 0
Me.Check5 = -1
Me.Check6 = 0
ElseIf Me.Box1 = "Text3" Then
Me.Check3 = 0
Me.Check5 = 0
Me.Check6 = -1
Else
Me.Check3 = 0
Me.Check5 = 0
Me.Check6 = 0
End If

Check3, Check5, and Check6 are the names of the three check boxes on the report.

Good Luck
 
Wicklund,

Thanks for your reply. I used the code below and am receiving a compile error: "Method or data member not found".

I wonder if it is because the combo box is on a form and the checkbox is on a report?


If Me.cboPreNoteType = "Original" Then
Me.chkOriginal = -1
Me.chkRevised = 0
Me.chkRescheduled = 0
Me.chkCanceled = 0
ElseIf Me.cboPreNoteType = "Revised" Then
Me.chkOriginal = 0
Me.chkRevised = -1
Me.chkRescheduled = 0
Me.chkCanceled = 0
ElseIf Me.cboPreNoteType = "Rescheduled" Then
Me.chkOriginal = 0
Me.chkRevised = 0
Me.chkRescheduled = -1
Me.chkCanceled = 0
ElseIf Me.cboPreNoteType = "Canceled" Then
Me.chkOriginal = 0
Me.chkRevised = 0
Me.chkRescheduled = 0
Me.chkCanceled = -1
End If

I've also tried using the name of the form (frmWorkorder) in place of "Me" and it didn't help.
 
In order for the code to work, the report needs to be 'associated' with the same table that your form is.

Then, you need the field that your checkbox value is stored in (cboPreNoteType) on the report. You can set the visibility of this field to 'No' if you don't want it to show up on the report, but it needs to be there.

Once this is done, your code should work.

Understand that data is not stored in a form, it is stored in a table. The form is just the interface to the data (I had to have this concept pounded into me rather hard before it sank in).

Good Luck,
 
Once I put the field on my report, it worked great. Thanks for your help.
 

Users who are viewing this thread

Back
Top Bottom