By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,078 Members | 2,164 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,078 IT Pros & Developers. It's quick & easy.

report print out is different from preview mode - please help.

P: n/a
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

Jan 27 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On 27 Jan 2006 15:32:31 -0800, Gary wrote:
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


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" .
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Jan 28 '06 #2

P: n/a
Gary wrote:
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

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.
Jan 28 '06 #3

P: n/a
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

Feb 6 '06 #4

P: n/a
Gary wrote:
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


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.
Feb 7 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.