Module to fill in Unbound Text Box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a report that can be used for multiple binders based on the results of
the query. I've created multiple command buttons on a form for the user to
click which binder they want. Its a simple procedure

Private Sub cmd2051f_Click()
DoCmd.OpenReport "rptGFTOC",acViewPreview, "qryIdahoToc",
"gf_2051_frms_dist = yes"
End Sub

What I would like to do is to add a statement to have the binder title go
into the report. The binder is 20.5.1.

I'm thinking something like the following, but I'm not sure how to make it
work.

Report!"rptGFTOC",txtbxTitle=20.5.1

Can I do that?
 
You can not set the value of a textbox on a report when in print or preview
mode.
The only option you have is to make a function which you can use in the
control source of this textbox.

Control Source property of your textbox should be set to =MyTitle()

and you should have the following code

public gTitle as string
public function MyTitle() as string
MyTitle=gTitle
end function

this function will pickup what you have set for the variable.
so you should add an event to the button and add the following code:

gTitle="my Title"
docmd.openreport "yourreport"

- Raoul
 
Raoul:

Thank you so much for your comments. This really helps. I'm just really
beginning to understand the process of programming. I would like help in
where I'm suppose to enter the code you identified.

public gTitle as string
public function MyTitle() as string
MyTitle=gTitle
end function

Thanks for your help.
 
Raoul:

I am very very very novice at this, but here is what I attempted and it did
not wrok. Can you guide me:

Report:
Created a textbox with a with the control source as: TOCTitle()

Form:
Created a command button
On Click Event Procedure
Private Sub cmd2051f_Click()
strTOCTitle = "GF 20.5.1"
DoCmd.OpenReport "rptGFTOC",acViewPreview, "qryIdahoToc",
"gf_2051_frms_dist = yes"
End Sub

public strTOCTitle as string
public function TOCTitle() as string
TOCTitle = strTOCTitle
end function

What is wrong:

I click on the button and a Parameter Value dialog opens wanting a
value for TOCTitle().

Please help.

Thanks.
 
Back
Top