Help (1 Viewer)

Cpar

Registered User.
Local time
Today, 03:04
Joined
Jan 9, 2016
Messages
41
Hey all! I have a question about printing forms. Basically i have a custom form with custom commands such as if statements and such. Everything is great and wonderful until i try and print the forms. For example i have a project # in which i filter my forms under. From that filter i then go into print preview screen. Now my problem is i have a if statement that hides maybe 10 fields if it another box has a "X" in it. So say my first form out of 5 im trying to print has a "X" in it so it hides some other fields. Well the other 4 forms im trying to print does not have a X in the field yet on the print preview it still shows the fields as hidden. I do not want that to happen. I want them to act independently. I hope this makes enough sense so someone can give me some ideas on why this is happening. Thanks in advance.
 

JHB

Have been here a while
Local time
Today, 10:04
Joined
Jun 17, 2012
Messages
7,732
Only for clarifying:
When you say 5 forms, is it 5 different forms, or the same form repeated 5 times?

Ps: No need for writing "Help" in the title of the thread, (we know you're here for getting help :)) - a few word describing your problem would be better.
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 04:04
Joined
Apr 27, 2015
Messages
6,396
Where are your "If" statements on the form/report? More specifically, are they part of the overall form properties are on the individual controls?

A copy of the statement would help as well.
 

Cpar

Registered User.
Local time
Today, 03:04
Joined
Jan 9, 2016
Messages
41
I am using a split form so data base on the bottom and form on top. However I have it only printing the form. So each record is its own form in a way. I do not have the exact code right now but it is taking place on the text box on change. The form on current and the form on load. I will try to get you the code in a few mins. The code on the form is working great though. Just not when I print.
 

Cpar

Registered User.
Local time
Today, 03:04
Joined
Jan 9, 2016
Messages
41
Private Sub Asfoundasleft_AfterUpdate()
If Asfoundasleft = "X" Then
Me.Label1141.Visible = False
Me.AsLeft0.Visible = False
Me.Asleft20.Visible = False
Me.Asleft40.Visible = False
Me.AsLeft60.Visible = False
Me.Asleft80.Visible = False
Me.Asleft100.Visible = False
Me.Label1138.Visible = False
Me.Label1156.Visible = False
Me.Label1160.Visible = False
Me.Asleftreading0.Visible = False
Me.Asleftreading20.Visible = False
Me.Asleftreading40.Visible = False
Me.Asleftreading60.Visible = False
Me.Asleftreading80.Visible = False
Me.Asleftreading100.Visible = False
Me.Asleftspan0.Visible = False
Me.Asleftspan20.Visible = False
Me.Asleftspan40.Visible = False
Me.Asleftspan60.Visible = False
Me.Asleftspan80.Visible = False
Me.Asleftspan100.Visible = False



Else
Me.Label1141.Visible = True
Me.AsLeft0.Visible = True
Me.Asleft20.Visible = True
Me.Asleft40.Visible = True
Me.AsLeft60.Visible = True
Me.Asleft80.Visible = True
Me.Asleft100.Visible = True
Me.Asleft100.Visible = True
Me.Label1138.Visible = True
Me.Label1156.Visible = True
Me.Label1160.Visible = True
Me.Asleftreading0.Visible = True
Me.Asleftreading20.Visible = True
Me.Asleftreading40.Visible = True
Me.Asleftreading60.Visible = True
Me.Asleftreading80.Visible = True
Me.Asleftreading100.Visible = True
Me.Asleftspan0.Visible = True
Me.Asleftspan20.Visible = True
Me.Asleftspan40.Visible = True
Me.Asleftspan60.Visible = True
Me.Asleftspan80.Visible = True
Me.Asleftspan100.Visible = True

End If


End Sub


Here is my code
 

Cpar

Registered User.
Local time
Today, 03:04
Joined
Jan 9, 2016
Messages
41
Still need help with this. If anyone has any ideas please let me know. I am having trouble printing
 

JHB

Have been here a while
Local time
Today, 10:04
Joined
Jun 17, 2012
Messages
7,732
The code is placed in the wrong event, you've it in the update event for a control, that event will only get fired if you change the value in the control, and that is not the case when you cycle through the different records, (yes - the value change, but you haven't edit the value, so the event isn't fired).
Place the code in the form's on current event instead.
...So each record is its own form in a way. ..
No not exactly - it is the same form but showing different data sets.
 

Cpar

Registered User.
Local time
Today, 03:04
Joined
Jan 9, 2016
Messages
41
So I delete the code from the as found/as left after update field? And just have it in the form on current? Because I have the same code in the form current and on load with it in the control after update. So it's on 3 different places. Thank you for having patience with helping me
 

Cpar

Registered User.
Local time
Today, 03:04
Joined
Jan 9, 2016
Messages
41
JHB This did not work. Anymore ideas?
 

JHB

Have been here a while
Local time
Today, 10:04
Joined
Jun 17, 2012
Messages
7,732
Post a stripped down version of your database with some sample code, (zip it) + name of the form in which you've the problem.
 

Cpar

Registered User.
Local time
Today, 03:04
Joined
Jan 9, 2016
Messages
41
Here is my sample.The problem im having is in form 1 when i print. You can put a X in the field under the left side chart and the right side will disappear. When you print (The button i have on the form) it will not listen to that X anymore. Sorry the late reply JHP. Thanks again.
 

Attachments

  • Sample.zip
    578 KB · Views: 59

JHB

Have been here a while
Local time
Today, 10:04
Joined
Jun 17, 2012
Messages
7,732
Sorry it can't be done, none of the events gets fired even if it is a form printed.
Maybe you can use the following solution:
Convert the form into a report, to do so:
Select the form in the navigation window, choose "File" ->"Save Object As". Type in a name for the report and choose "Report" in the combo box.
Then put your code into the format event in the detail section.
One sample attached.
 

Attachments

  • Sample7.zip
    580.8 KB · Views: 65

Cpar

Registered User.
Local time
Today, 03:04
Joined
Jan 9, 2016
Messages
41
JHB i am alright with how you set this up (In a way). If you don't mind helping me fine tune in a bit that would be great! I am almost to the end i can see it!!! If i want to filter by report number. How do i get the button to filter it going into the report preview view? Maybe it asks me what report number i want before redirecting me?

Also if you could explain what ([Main Data Base].[Report #] Is Not Null AND [Main Data Base].[Report #]<>"") means in the report filter that would be awesome.

Thanks again JHB you have really helped a lot! Like i said a few more kinks i need to get out then i am done!
 

Cpar

Registered User.
Local time
Today, 03:04
Joined
Jan 9, 2016
Messages
41
Also something i do not quite understand is why it will work in a report but not a form.
 

JHB

Have been here a while
Local time
Today, 10:04
Joined
Jun 17, 2012
Messages
7,732
JHB i am alright with how you set this up (In a way). If you don't mind helping me fine tune in a bit that would be great! I am almost to the end i can see it!!! If i want to filter by report number. How do i get the button to filter it going into the report preview view? Maybe it asks me what report number i want before redirecting me?
I've made 2 solution for you in the attached database.
Also if you could explain what ([Main Data Base].[Report #] Is Not Null AND [Main Data Base].[Report #]<>"") means in the report filter that would be awesome.
It is not a filter I've put in, it is coming from the form as I convert it.
But I can explain what it means:
It say, if the field [Report #] in the table [Main Data Base] is not Null and the same field is different to "" (empty string) the show the data.
Some good advice is not to use special characters in field names like "#", "&" etc., and spaces isn't good either.
 

Attachments

  • Sample7 (2).zip
    581.4 KB · Views: 56

Cpar

Registered User.
Local time
Today, 03:04
Joined
Jan 9, 2016
Messages
41
JHB I was able to get the filter into a report on click working! That works great. I just do not understand why my real document cannot get it to show right. Meaning whatever my first form does for the "X" the rest follow even if it does not have a "X" in it. What could i possbily be doing wrong? I feel like i copied your thing almost perfectly. Please help!
 

JHB

Have been here a while
Local time
Today, 10:04
Joined
Jun 17, 2012
Messages
7,732
What could i possbily be doing wrong? I feel like i copied your thing almost perfectly. Please help!
I'm not sure what you exactly mean, can you clarify?
If you mean why you can't print the form directly, then it is because none of the form's events are triggered when the form is printed.
 

Cpar

Registered User.
Local time
Today, 03:04
Joined
Jan 9, 2016
Messages
41
I mean I can't print with the options you gave me when I change the forms to reports. That was my problem is when I try and print they do not come out like they do on the screen. It works in the sample you gave me but not on my original document.
 

JHB

Have been here a while
Local time
Today, 10:04
Joined
Jun 17, 2012
Messages
7,732
Did you put in the code in the detail on format in the report?

Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Asfoundasleft = "X" Then
Me.Label1141.Visible = False
Me.Asleft20.Visible = False
Me.Asleft40.Visible = False
Me.AsLeft60.Visible = False
Me.Asleft80.Visible = False
Me.Asleft100.Visible = False
Me.Label1138.Visible = False
Me.Label1156.Visible = False
Me.Asleftreading0.Visible = False
Me.Asleftreading20.Visible = False
Me.Asleftreading40.Visible = False
Me.Asleftreading60.Visible = False
Me.Asleftreading80.Visible = False
Me.Asleftreading100.Visible = False

Else
Me.Label1141.Visible = True
Me.Asleft20.Visible = True
Me.Asleft40.Visible = True
Me.AsLeft60.Visible = True
Me.Asleft80.Visible = True
Me.Asleft100.Visible = True
Me.Asleft100.Visible = True
Me.Label1138.Visible = True
Me.Label1156.Visible = True
Me.Asleftreading0.Visible = True
Me.Asleftreading20.Visible = True
Me.Asleftreading40.Visible = True
Me.Asleftreading60.Visible = True
Me.Asleftreading80.Visible = True
Me.Asleftreading100.Visible = True

End If



End Sub
 

Cpar

Registered User.
Local time
Today, 03:04
Joined
Jan 9, 2016
Messages
41
JHB i can see why you have been thanked over 1000 times. I will make sure to add another!
 

Users who are viewing this thread

Top Bottom