Hello,
I'm hoping someone can shed some light on why my report does not output
the same results as shown in preview mode, which is to move the
position of a check box based on a field value (see code below). The
code does exactly what I want only in preview mode; it moves the check
box only when the drug criteria is true. However, when I print the
report the check box position remains unchanged.
I tried putting the same code to both the Print and Format events but I
get error message 2101, the setting you entered isn't valid for this
property and highlights the line "intTop = 0.0208. I tried to
troubleshoot the setting but I'm not getting anywhere. I can't figure
out why Access only lets me preview the results and not print them.
I promised my boss this was doable but I'm not sure what I'm doing
wrong. If anyone could give me any help/comments I would truly
appreciate it.
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim check As CheckBox
Dim intTop As Integer
Set check = Me.ChkBox202
If Nz([Drug].Value) = "Acetaminophen" Then
intTop = 0.0208
With check
.Top = intTop
End With
End If
fredg - 28 Jan 2006 01:02 GMT
> Hello,
> I'm hoping someone can shed some light on why my report does not output
[quoted text clipped - 30 lines]
>
> End If
1) All measurements in Access are measured in Twips, 1440 per inch.
If your Top is just 0.0208 (Twips) you cannot see any movement.
2) Once you move it, nowhere in your code do you move it back if the
[Drug] value is not "Aceteminophen".
Your Preview code moved it, but then it was not re-set.
3) You have gone some hoops of coding to do a rather simple thing.
4) I assume ChkBox202 is the name of the check box on the report
detail section you wish to move.
Try it this way in the Detail Format event:
If [Drug] = "Acetaminophen" Then
ChkBox202.Top = 0.0208 * 1440
Else
ChkBox202.Top = ? * 1440
End if
Replace the ? with the measurement (in inches) that you want the Top
to be if the [Drug] value is not "Acetaminophen" .

Signature
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
salad - 28 Jan 2006 01:09 GMT
> Hello,
> I'm hoping someone can shed some light on why my report does not output
[quoted text clipped - 30 lines]
>
> End If
Just curious...what happens if you enter
If Nz([Drug].Value) = "Acetaminophen" Then
Me.ChkBox202.Top = 0.0208
Endif
One other thing. Run this code
Sub adsfasdfa()
Dim intTop As Integer
intTop = 0.0208
MsgBox intTop
End Sub
intTop in the msgbox is 0. However, if I change intTop to type Double I
get 0.0208.
Gary - 06 Feb 2006 19:15 GMT
Thank you!!! Thank You!! To both "Fredg" & "salad" for your great
feedback.
Fredg, you're right about everything you stated but handling the
checkbox position when the drug value was not "acetaminophen" was key
and in addition "salad's" suggestion; changing the intTop to Double
made
the whole thing come together. Finally----it WORKS!!! :>
This is the code I used:
Dim Check As CheckBox
Dim intTop As Double
Dim intTop2 As Double
Set Check = Me.Check202
If Nz([TradeDrug].Value) = "Acetaminophen" Then
intTop = 0.0208 * 1440
Me.Order_Format.Top = intTop
With Check2
.Top = intTop
End With
Else
intTop2 = 0.0988 * 1440
With Check2
.Top = intTop2
End With
End If
salad - 06 Feb 2006 23:51 GMT
> Thank you!!! Thank You!! To both "Fredg" & "salad" for your great
> feedback.
[quoted text clipped - 30 lines]
>
> End If
Somehow my newsreader dropped my to this message when it opened...I
rarely look at old messages. Anyway...Great news on your part!!!!
What I've done sometimes is I'll move a control to a position. Let's
say I want Left and Top and Width.
I'll input in the GotFocus event
msgbox "Left " & Me.TextField.Left & vbNewLine & _
msgbox "Top " & Me.TextField.Top & vbNewLine & _
msgbox "Width " & Me.TextField.Width
Now I write the results of the messagebox down somewhere. Then I move
the control somewhere else. Run the same process. Now I know the
values I want to assign depending on a particular action.