Change Properties OnOpen

scotthutchings

Registered User.
Local time
Today, 15:08
Joined
Mar 26, 2010
Messages
96
I am trying to adjust my report based on the values chosen by the user. The user can choose whether to see a manufacturer and whether to see opening information (2 fields on the report are affected). Something has gone amiss because it is not working. Here is my code:
Code:
Private Sub Report_Open(Cancel As Integer)
If Forms![Bid - Vendor Quotes]![Bid - Quote]!optShowMfr = -1 Then
    If Forms![Bid - Vendor Quotes]![Bid - Quote]!optShowOpening = -1 Then
        'Open full report
        
    Else
        'Show Mfr, Hide Openings
        Me.Opening.Visible = False
        Me.OpeningLabel.Visible = False
        Me.QtyPerOpening.Visible = False
        Me.QPOLabel.Visible = False
        Me.Description.Width = 3.5729
        Me.Item_Label.Width = 3.5729
    End If
Else
    If Forms![Bid - Vendor Quotes]![Bid - Quote]!optShowOpening = -1 Then
        'Hide Mfr, Show Opening
        Me.Mfr.Visible = False
        Me.MfrLabel.Visible = False
        Me.Description.Left = 0.6875
        Me.Description.Width = 2.5313
        Me.Item_Label.Left = 0.6875
        Me.Item_Label.Width = 2.5313
        
    Else
        'Hid Mfr, Hide Openings
        Me.Opening.Visible = False
        Me.OpeningLabel.Visible = False
        Me.QtyPerOpening.Visible = False
        Me.QPOLabel.Visible = False
        Me.Mfr.Visible = False
        Me.MfrLabel.Visible = False
        Me.Description.Left = 0.6875
        Me.Description.Width = 4.4063
        Me.Item_Label.Left = 0.6875
        Me.Item_Label.Width = 4.4063
    End If
End If
The appropriate fields are not visible, but when it runs any of the options to modify the location and width of the Description field, the field does not show up. Any ideas?

Thanks!
Scott
 
What is the different between the following lines:
If Forms![Bid - Vendor Quotes]![Bid - Quote]!optShowOpening = -1 Then
'Open full report

AND
this one:

Else
If Forms![Bid - Vendor Quotes]![Bid - Quote]!optShowOpening = -1 Then
'Hide Mfr, Show Opening


These seem to be same line of codes with multi else statements, you can make it easy by using the Select Case Statement:

Select Case Expression
Case Expression_1
Statement_1
Case Expression_2
Statement_2
Case Expression_n
Statement_n
...
End Select
 
It is a nested If..Then statement. They are the same. The first one is evaluated when the previous condition is 0 and the second is evaluated when the previous condition is -1. The results are different.
 
Showing and hiding stuff doesn't go in the report's On Open event. It has to be in the On FORMAT event of the section that it is in.
 
When I move this code into the On Format event of the detail section, It creates 10 blank lines (there are 10 items on my quote) for each item and still the Description is not visible. As I step through the code, it steps through the code 10 times for each my my 10 records. If I do not run any of this code, the report works fine. There must be something else to moving controls around on a report that I am missing.
 
I figured it out. The code is run from the On Open event. The problems is that when setting the property using VBA, I must convert my inch dimension to twips (1" = 1440 twips). The code above sets the width of my description field to 3.5729 twip which isn't very large. If I change the code to read:
Code:
 me.description.width = 3.5729*1440
then is correctly formats it to 3.5729 inches.

Thanks for your input.
 
When I move this code into the On Format event of the detail section, It creates 10 blank lines (there are 10 items on my quote) for each item and still the Description is not visible. As I step through the code, it steps through the code 10 times for each my my 10 records. If I do not run any of this code, the report works fine. There must be something else to moving controls around on a report that I am missing.

Well you are missing something. Dimensions in VBA need to be made in TWIPS not inches. So there are 1440 TWIPS to an Inch. So, if you have this:
Me.Description.Width = 3.5729
Me.Item_Label.Width = 3.5729

Then you are just showing it at 3.6 TWIPS which is very, very, very, very small.

Do what I do and put in a Constant like this at the TOP of your code

Const TW As Integer = 1440


and then use this where you need widths (or heights):

Me.Description.Width = 3.5729 * TW
Me.Item_Label.Width = 3.5729 * TW
 
I miss the cross TWIPs of replies :p coz I was away :)
Should I believe that Khalid?
smiletongueout.jpg
 

Users who are viewing this thread

Back
Top Bottom