Formating Text box in Report from a Form (1 Viewer)

thudson

Old Programmer
Local time
Today, 05:09
Joined
Apr 29, 2011
Messages
68
I am trying to position a text box on a report using the Left, Top etc properties.
In the form which opens this Report are some text box fields which contain the position value.
Even though the button calling the report is on the form, it errors saying ' Microsoft Access cannot find the referenced form. Here is the code:

Private Sub Cmd_Open_Rep_Click()
Dim strWhere As String 'The criteria string.

DoCmd.OpenReport "Rep_Port_Grt", acViewPreview, acDialog, strWhere
Me!Text1.Height = Forms![Frm_Card_Parms]![Ht_Sz]
Me!Text1.Width = Forms![Frm_Card_Parms]![Wth_Sz]
Me!Text1.Left = Forms![Frm_Card_Parms]![Lft_Posn]
Me!Text1.Top = Forms![Frm_Card_Parms]![Top_Dim]

End Sub

Where am going wrong?

Also, I want to use some text that I have selected in a previous form which has been selected from an SQL query:
SELECT Verses.VerseID, Verses.EventID, Verses.MoodID, Verses.Verse, Events.EventID, Events.Event_Type, Moods.MoodID, Moods.Mood_Type, Verses.Tick_Box
FROM Moods INNER JOIN (Events INNER JOIN Verses ON Events.EventID = Verses.EventID) ON Moods.MoodID = Verses.MoodID
WHERE (((Events.Event_Type) Like fCboSearch([Forms]![Frm_Verse_Cbo]![cbo_Evt])) AND ((Moods.Mood_Type) Like fCboSearch([Forms]![Frm_Verse_Cbo]![Cbo_Md])))
ORDER BY Verses.VerseID;
How do I get that to be written into the text box?
 

Ranman256

Well-known member
Local time
Today, 00:09
Joined
Apr 9, 2015
Messages
4,337
1. everything in the report comes from a query, so if you want data in the form/report, put it in the query.

2. WHY would you adjust report objects on the fly. Just put them on the report and forget about it. (which may be the problem, because once you see the report you cant format it.) Above you are trying to reformat AFTER the report opens.
set it in design and forget it.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 23:09
Joined
Feb 28, 2001
Messages
27,219
Ranman's comment #1 is spot-on.

Comment #2 is correct, but there is such a thing as opening the report in acDesign mode (or whatever the option is called) and placing the controls, closing the report, and save it, and then open it in acReportView. In design view, you cannot see data. In report view, you cannot move controls. End of discussion.
 

thudson

Old Programmer
Local time
Today, 05:09
Joined
Apr 29, 2011
Messages
68
Perhaps if I explain what I am trying to acheive you may be able to advise which method would be best to achieve my ultimate goal.
I have a utility on my website which allows you to choose a verse for a home made greetings card from a database of nearly 1000 verses. You can see this by going to 1066cards4u.co.uk and clicking on the Verses tab and the first button.
This allows the user to choose a verse after filtering the event type and the mood.
when a selection is made a configuration form is shown, allowing the user to choose the size of card, the distance from the top, the Font and font color and a couple of other things that are not so important. when these have been selected I am using a PHP script that produces a PDF file from the selections made, with the text positioned for that size of card.

So I am now trying to mimic this using Access VBA/ VB.
I could as you say, set the report parameters in a report for each of the card sizes, but to date I have 41 different sizes, so I thought I may be able to set the textbox position and size dynamically and then get the text to be placed in the textbox. the above code was my attempt to do this.
Am I approching the problem incorrectly?
The Doc Man said that I could open the report in acDesign mode then save it and then reopen in acReportPreview. Could I then destroy that report, using code, so that I don't accumilate hundereds of reports?
Would this be the way to takle this problem?
If anybody can give me some advice I would be most grateful!
 

JHB

Have been here a while
Local time
Today, 06:09
Joined
Jun 17, 2012
Messages
7,732
Use the reports on open event.
Sample attached - open the form, type some value in, then click the button.
 

Attachments

  • ControlChangeIReport.accdb
    364 KB · Views: 105

thudson

Old Programmer
Local time
Today, 05:09
Joined
Apr 29, 2011
Messages
68
Thank you JHB!
That worked OK!
Was the Me. in the first statement a typo? I changed it to an !.
I have another thread called 'Select records from a form using a Tick Box', don't know if you can help there. It's in Forms.
Thanks for thehelp!
 

thudson

Old Programmer
Local time
Today, 05:09
Joined
Apr 29, 2011
Messages
68
Just found a problem!
The Cmd button opens the report, but as my form has a filter based on this technique (see allenbrowne.com/ser-62.html). It selects a record from 41 records based on what is selected in the unbound combo box. This record has the dimensions in twips for the 4 controls I want to use. However when I click on the button to open the report, there are 41 pages. So it must be generating a page for each of the records in the report.
How can I limit the report to only the record I have selected in the unbound combo box?
 

JHB

Have been here a while
Local time
Today, 06:09
Joined
Jun 17, 2012
Messages
7,732
Set the filter in the report as you've in the form.
 

JHB

Have been here a while
Local time
Today, 06:09
Joined
Jun 17, 2012
Messages
7,732
Was the Me. in the first statement a typo? I changed it to an !.
No it is normal to use .
I've copied some of you code therefore the ! was used, (I haven't seen it).
 

thudson

Old Programmer
Local time
Today, 05:09
Joined
Apr 29, 2011
Messages
68
[FONT=&quot]Hi JHB

The filter I have used is in code using AllenBrownes code.
So I pasted acopy of this in the Open Report Event of the report, but it still has 41 pages?
I noticed that this writes the filter code into the Filter Property of the form, so how do you get this code to change the Report Filter?

Tried to p[FONT=&quot]o[/FONT]st code but the Forum won't let me!!
Who's stupid idea is it to stop people sending code until you have done 10 posts??

[/FONT] Any suggestions?
 

JHB

Have been here a while
Local time
Today, 06:09
Joined
Jun 17, 2012
Messages
7,732
Zip your database - then you can post it before 10 post.
I think it is done for preventing junk post.
 

thudson

Old Programmer
Local time
Today, 05:09
Joined
Apr 29, 2011
Messages
68
Hi JHB

The database is in an experimental stage, where I have been trying out different ideas.
For the code we have been discussing use Frm_Card_Params.

The other post on the forum (Forms) uses:
Frm_Verse_Cbo
Thanks for your help!
 

Attachments

  • MyGreeting.zip
    343.4 KB · Views: 74

JHB

Have been here a while
Local time
Today, 06:09
Joined
Jun 17, 2012
Messages
7,732
The report part has been fixed, database attached.
 

Attachments

  • MyGreeting.zip
    147.2 KB · Views: 83

Users who are viewing this thread

Top Bottom