stevid
asked on
How to test a Control on a Access Report
i have an access form which has a checkbox that can be ticked or not labeled discount
If i click Discount on the form a discount box appears and allows the user to enter a discount value,
Now i have a report that displays the invoice but i only want the discount box to show on the report if dicount has been ticked in the form already,
How do i test if for this particular record discount has been ticked and subsequently make the discount box appear and change the font colour,
Any ideas??
Thanks,
If i click Discount on the form a discount box appears and allows the user to enter a discount value,
Now i have a report that displays the invoice but i only want the discount box to show on the report if dicount has been ticked in the form already,
How do i test if for this particular record discount has been ticked and subsequently make the discount box appear and change the font colour,
Any ideas??
Thanks,
When the form applies the discount, then there must be some indicator in the underlying table(s). Those indicators (discount%, perhaps?) need to be passed to the report. Probably the easiest way is to add a discount field to the form's record source. Conditional formatting of the report based on a column in the Record Source is trivial.
Try something like this perhaps:
If me.DiscountChecboxControlF ield=True Then
Me.txtDiscountAmount.visbl e=True
ElseIf me.DiscountChecboxControlF ield=False Then
Me.txtDiscountAmount.visbl e=False
End if
<make the discount box appear and change the font colour,>
I'm confused, if the box is not visible, the font color is irrelevant...
Perhaps you should list the *exact* field names and control names of all the objects involved please?
(So we know if you are referring to the discount check "Box" or the Discount amount Text"Box")
In any event, you can select the control in design view, and click "Conditional" to conditionally format the font based on a condition.
JeffCoachman
If me.DiscountChecboxControlF
Me.txtDiscountAmount.visbl
ElseIf me.DiscountChecboxControlF
Me.txtDiscountAmount.visbl
End if
<make the discount box appear and change the font colour,>
I'm confused, if the box is not visible, the font color is irrelevant...
Perhaps you should list the *exact* field names and control names of all the objects involved please?
(So we know if you are referring to the discount check "Box" or the Discount amount Text"Box")
In any event, you can select the control in design view, and click "Conditional" to conditionally format the font based on a condition.
JeffCoachman
...Oh, ...my code would go on the Format event of the Detail Section.
Then the report must be opened in "Print Preview" specifically.
Then the report must be opened in "Print Preview" specifically.
ASKER
yes i have a simple tick box, discount
If you tick it the discount boxs appear and if its false they stay hidden
This tick box value is stored in the underlying tables, I have it passed to the report also,
I have been trying to use the onload event for the form to test the control and then usinf IF statements to say display or not but no good
If you tick it the discount boxs appear and if its false they stay hidden
This tick box value is stored in the underlying tables, I have it passed to the report also,
I have been trying to use the onload event for the form to test the control and then usinf IF statements to say display or not but no good
ASKER
I need this to also work if i print or just display the form
ASKER
Tick Box = [apply discount]
Text Box i want to show and hide = [txtTotalIncDis]
Text Box i want to show and hide = [txtTotalIncDis]
ASKER
Here is the code i have,
If Me.Apply_Discount.Value = True Then
Me.txtTotalIncDis.Visible = True
Else
Me.txtTotalIncDis.Visible = False
End If
Cant get it to work though, I reckon its to do with what event is generating it
If Me.Apply_Discount.Value = True Then
Me.txtTotalIncDis.Visible = True
Else
Me.txtTotalIncDis.Visible = False
End If
Cant get it to work though, I reckon its to do with what event is generating it
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You'll have to be a bit more specific when you say:
"Cant get it to work though,"
;-)
...And try to avoid spaces in your object names.
The "_" that vba inserts is a generic character it uses for any character it does not like...
(See here for notes on standard naming conventions:
http://www.xoc.net/standards/rvbanc.asp
http://en.wikipedia.org/wiki/Leszynski_naming_convention)
So in the format event of the detail section, it would look something like this:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.chkApplyDiscount.Value = True Then
Me.txtTotalIncDis.Visible = True
Else
Me.txtTotalIncDis.Visible = False
End If
End sub
Finally, remember you *Must* Open the report in "Print Preview" explicitly, to see this work.
;-)
JeffCoachman
"Cant get it to work though,"
;-)
...And try to avoid spaces in your object names.
The "_" that vba inserts is a generic character it uses for any character it does not like...
(See here for notes on standard naming conventions:
http://www.xoc.net/standards/rvbanc.asp
http://en.wikipedia.org/wiki/Leszynski_naming_convention)
So in the format event of the detail section, it would look something like this:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.chkApplyDiscount.Value = True Then
Me.txtTotalIncDis.Visible = True
Else
Me.txtTotalIncDis.Visible = False
End If
End sub
Finally, remember you *Must* Open the report in "Print Preview" explicitly, to see this work.
;-)
JeffCoachman
ASKER
Any ideas how i can get the above to work when i open it in normal view or print preview???
Thanks,
Thanks,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
No its a report alright,
I have it all working on the form part fine??
I have it all working on the form part fine??
ASKER
Sorry was not a question above,
I have the form set up and the Discount Box appear and dissapear as i want,
I now want this to work on the Report for the form,
I have the form set up and the Discount Box appear and dissapear as i want,
I now want this to work on the Report for the form,
Can you post the database.
ASKER
not really,
It contains a lot of confidentail info and is based on a back end also,
I could export the form and report in question but it is based on back end tables so not sure how well that would work??
It contains a lot of confidentail info and is based on a back end also,
I could export the form and report in question but it is based on back end tables so not sure how well that would work??
<No its a report alright,>
Ok, this was confusing:
<How to test a Control on a Access Report>
then...
<i have an access form which...>
So again, this code should work on the Detail_Format event.
I'll back out now, I am sure dqmq can handle it from here...
Ok, this was confusing:
<How to test a Control on a Access Report>
then...
<i have an access form which...>
So again, this code should work on the Detail_Format event.
I'll back out now, I am sure dqmq can handle it from here...
Sure, export the report, and if possible, copy the report's recordsource into a make table query and give us a few rows of actual data. You can change names and places, etc. to protect the innocent.
ASKER
Ok have changed it all around and now just have a permanent special pricing box so everyone gets a special price :-)