views:

50

answers:

2

is it possible in access 2007 to draw an X during runtime at a specified point on the report during runtime?

+1  A: 

Well I’m not Fenton but I will give it a bash! Here is a sample of code from a report that is part of a multiple choice testing system, it puts a cross if you get the answer wrong and a tick if you get it right, ohh and a flag if you get it part right

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.imgCross.Visible = False
Me.imgFlag.Visible = False
Me.imgTick.Visible = False
Select Case Me.txtMax_score - Me.txtAnswer_value
    Case 0
        'user got the question 100% right, show the tick image
        Me.imgTick.Visible = True
    Case Is = Me.txtMax_score
        'user got the question completely wrong show the cross image
        Me.imgCross.Visible = True
    Case Else
        'not 100% right but not completly wrong, show the flag
        Me.imgFlag.Visible = True
End Select
End Sub

The images or just normal images that get hidden by the code and are just stacked on top of each other

Kevin Ross
+1  A: 

You may want to look into the Line method for drawing lines on reports. It's hard to find the help for this -- the easiest way is to open the VBE, type "line" in the immediate window, hit F1 for help, and then choosing the Access Line choice (not VBA or the Line (object) choice).

This allows you to specify a line with x/y coordinates.

However, that's the easy part.

Determining what x and y should be is not trivial if you're drawing something in one of the printable areas of a report, particularly for areas that can resize at format time. I have never used this except to draw vertical lines in subreports whose height is variable, so can't really give any useful advice on this. But you can experiment and see.

I would suggest, however, that you may be using the wrong tools if you think you need to do it this way. Display an X may be as easy as creating a label with X as its caption and then control the visible property based on criteria tested at runtime.

David-W-Fenton