Form set the Visibility of a Label in a Report?

D

dohernan

I have a form, if a person puts a "y" in the Jean Field I want to store that
info until the person finishes filling out the form then clicks on a Command
Button to open a Report/Letter.

When that Report/Letter is opened, if there's a "y" in the Jean Field I want
the Jean Signature label to be visible in the Report.
It has a default of another name label visible, with the Jean one defaulted
to not visible.

People can do the Report without the Jean label, so I can't just tie that
command to the 'Create Report" button... unless it can check and see if they
picked 'y' on the Jean Field?

The name of the Label-
JeanSignatureLabel

Thanks.

Thoughts so far, in the Form-
Private Sub Jean_AfterUpdate()

If Me.[Jean] = "y" Then
DoCmd.RunCommand acCmdSaveRecord, , _
"[AddressRecord] = " & Me.AddressRecord, , "J"

End If
End Sub

In the Report-
Private Sub Report_Open(Cancel As Integer)

If IsNull(Me.OpenArgs) Then
Me.JeanSignatureLabel.Visible = False
Else
Me.JeanSignatureLabel.Visible = True

End If
End Sub

I'm not quite sure how to pull this together, thanks.
 
J

John Smith

Put your Jean field in the OpenArgs parameter (using your own report name etc):

DoCmd.OpenReport ReportName, View, FilterName, WhereCondition, WindowMode, Jean

Then in the report:

Private Sub Report_Open(Cancel As Integer)
Me.JeanSignatureLabel.Visible = (Nz(Me.OpenArgs) = "y")
End Sub

HTH
John
##################################
Don't Print - Save trees
 
D

dohernan

Thanks very much. I'm new to this all.
If "y" is picked and the person wants to view the report, I want the report
to show the current record as well as set the name label. I tried to do
something like the code below, but it doesn't work.


Private Sub Form_Open(Cancel As Integer)

DoCmd.OpenReport "TempVerifLetter", acPreview, , _
WhereCondition [Me.Jean]="y", WindowMode:=acDialog, [Jean]
"[AddressRecord] = " & Me.AddressRecord

End Sub
 
J

John Smith

Sorry for the delay, we moved offices on Friday and are only just getting straight!

You are almost there but have your criteria in the wrong place. Try:

DoCmd.OpenReport "TempVerifLetter", acPreview, , _
"[AddressRecord] = " & Me.AddressRecord, acDialog, [Jean]

This assumes that AddressRecord is numeric. If it is a string then you would need:

"[AddressRecord] = '" & Me.AddressRecord & "'"

HTH
John
##################################
Don't Print - Save trees
Thanks very much. I'm new to this all.
If "y" is picked and the person wants to view the report, I want the report
to show the current record as well as set the name label. I tried to do
something like the code below, but it doesn't work.


Private Sub Form_Open(Cancel As Integer)

DoCmd.OpenReport "TempVerifLetter", acPreview, , _
WhereCondition [Me.Jean]="y", WindowMode:=acDialog, [Jean]
"[AddressRecord] = " & Me.AddressRecord

End Sub





John Smith said:
Put your Jean field in the OpenArgs parameter (using your own report name etc):

DoCmd.OpenReport ReportName, View, FilterName, WhereCondition, WindowMode, Jean

Then in the report:

Private Sub Report_Open(Cancel As Integer)
Me.JeanSignatureLabel.Visible = (Nz(Me.OpenArgs) = "y")
End Sub
 
D

dohernan

Thanks again, hope the move went smoothly, we just moved in May.

I have an "Open report/Create Letter" button that's supposed to check if
[Jean] if set to "y", but the report gets opened either way, just one way
shows Jean as the signature, and the other way has a Helene signature label
visible by default. I need to set that label "behind".

AddressRecord is numerical. :)

Here's what I have-

Private Sub VerificationLetterButton_Click()
On Error GoTo Err_VerificationLetterButton_Click

Dim stDocName As String

stDocName = "TempVerifLetter"
DoCmd.OpenReport "TempVerifLetter", acPreview, , _
"[AddressRecord] = " & Me.AddressRecord, acDialog, [Jean]


Exit_VerificationLetterButton_Click:
Exit Sub

Err_VerificationLetterButton_Click:
MsgBox Err.Description
Resume Exit_VerificationLetterButton_Click

End Sub

Thanks again.
 
D

dohernan

Got the labels working with what I have below.
Is there some way to say = not "y" just in case people leave it blank or
type something else, instead of specifically saying "n"?

Thanks so much. ^^

Private Sub Report_Open(Cancel As Integer)

Me.JeanSignatureLabel.Visible = (Nz(Me.OpenArgs) = "y")
Me.SigHeleneHolloway.Visible = (Nz(Me.OpenArgs) = "n")

End Sub
 
J

John Smith

Yes indeed:

Me.SigHeleneHolloway.Visible = (Nz(Me.OpenArgs) <> "y")

or you could have:

Me.SigHeleneHolloway.Visible = Not Me.JeanSignatureLabel.Visible

which ensures that you will always have exactly one visible!

John
##################################
Don't Print - Save trees
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top