473,480 Members | 1,536 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Moving controls in report based on the data

Seth Schrock
2,965 Recognized Expert Specialist
I may be trying the impossible. I'm trying to print multiple records on preprinted forms. However, each record may be on different forms. There will always be at least to different formats. So what I have done is to create a table that specifies the width, height, top and left properties for each control based on the form type needed by a specific record. At the bottom of the Detail section of the report, I have a page break so that each record will be on its own page. So I have my code that loops through the controls and sets the various size/position properties.
Expand|Select|Wrap|Line Numbers
  1. Dim db As DAO.Database
  2. Dim strControls As String
  3. Dim rstControls As DAO.Recordset
  4.  
  5. Set db = CurrentDb
  6.  
  7. strControls = "SELECT ControlName, Visible, Width, Height, Top, Left, FontSize, TextAlign " & _
  8.               "FROM TicketSpecs WHERE TicketTypeID_fk = " & Me.txtTicketType
  9.  
  10. Set rstControls = db.OpenRecordset(strControls, dbOpenDynaset)
  11.  
  12. With rstControls
  13.     Do While Not .EOF
  14.         With Me.Controls(!ControlName)
  15.             If rstControls!Visible Then
  16.                 .Visible = True
  17.                 .Width = rstControls!Width
  18.                 .Height = rstControls!Height
  19.                 .Top = rstControls!Top
  20.                 .Left = rstControls!Left
  21.                 .FontSize = rstControls!FontSize
  22.                 .TextAlign = rstControls!TextAlign
  23.             Else
  24.                 .Visible = False
  25.             End If
  26.  
  27.         End With
  28.         .MoveNext
  29.     Loop
  30. End With
  31.  
  32.  
  33. Set db = Nothing
  34. rstControls.Close
  35. Set rstControls = Nothing
Now my problem is in which event to I call this. I had put it in the report's On_Current event, but I have to actually click on each record for this to run. Even in print preview while cycling through the pages doesn't trigger it. Also, as soon as it tries to change the Width property, the control becomes invisible. I thought maybe a repaint was needed, but I can't find a command for that.

I had thought of having a different report for each form and then just looping through the records calling each report as needed, but then either I would have to use the default printer or be asked which printer I want to use for every single record. Not what I'm wanting to happen.
Apr 29 '14 #1
6 2041
jimatqsi
1,271 Recognized Expert Top Contributor
Anything changing object visibility, position or size on a report must be addressed in the On Format event.

Jim
Apr 29 '14 #2
Seth Schrock
2,965 Recognized Expert Specialist
Okay, I have put it in the Detail On_Format event. However it is still making them invisible as soon as I try to make the size/position changes. I also tried using the Move method, but I get the same result.
Apr 29 '14 #3
jimatqsi
1,271 Recognized Expert Top Contributor
A With within a With creeps me out. So does using Access keywords/properties for field names.

Jim
Apr 29 '14 #4
Seth Schrock
2,965 Recognized Expert Specialist
I had tried removing the outside WITH and it doesn't change anything. Nested WITHs are fully supported. Also, Width and Height are not reserved words (Top and Left are. I didn't think of those as reserved words when I created this.) I have never heard of property names causing problems as field names. However, I have now added an f in front of each field name (for field) and no change.
Apr 29 '14 #5
jimatqsi
1,271 Recognized Expert Top Contributor
Seth,
What values are you using for top and height and width? Are you specifying units of measure? Try hard-coding the position of one object; or put an object like an empty text-box myTB at a particular place on the form and make one of your objects move by using
Expand|Select|Wrap|Line Numbers
  1. someobj.top = myTB.top
  2. someobj.height=myTB.height
etc...

I've done this sort of things lots.In fact, NeoPa invited me to be a Bytes expert because he saw one of my report functions for aligning headings and data in a case where columns could be made invisible based on the data.

I'd bet it's a problem of units of measure.

Jim
Apr 29 '14 #6
Seth Schrock
2,965 Recognized Expert Specialist
That fixed it. I just had tried both inches and twips, but neither worked. The problem was when I used the twips, I just multiplied the inches by 1440, but the resulted in some decimal values and evidently it only works with integers. Thanks Jim.
Apr 29 '14 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
6590
by: Richard | last post by:
Hi, I have a form based on a table. When I filter the form I want to run a report based on the same table with the same filter as the form. No problem until I want to filter a combo box where...
1
1589
by: Andrew | last post by:
What I'm trying to have done is the following: After data is entered into a form, I want the user to click the "Submit and print" button, which solidifies the data in the tables, then prints a...
1
1808
by: Andrew | last post by:
How do I set up a report that runs after the user selects a month, (from a combo or list box on a form) so that the only data in the report is data from the month selected? I'm not too good with...
1
2311
by: davidbennett | last post by:
Hello, I am new to MS Access. I have created a series of forms that users access to perform data entry. I now need to build in reporting functionality. I would like to create a form that has a...
1
2003
by: gregoryenelson | last post by:
Hi all. I have created a Report with a graph also on it. The users, working through a form only (not the DB window) will want to view that Report run numbers of times against different criteria,...
7
10800
by: =?Utf-8?B?TW9iaWxlTWFu?= | last post by:
Hello everyone: I am looking for everyone's thoughts on moving large amounts (actually, not very large, but large enough that I'm throwing exceptions using the default configurations). We're...
26
3826
by: vishwaskothari | last post by:
I am to make a data report in which I am going to display the records dynamically from the database. No. of record depends on the users input. How can I do this? I think an array of controls can...
3
1797
LeighW
by: LeighW | last post by:
Hi there, Everytime a user edits data within the bound forms in the database the approval checkbox (which is a bound field) changes to "False". Is there a way of creating one sole report based...
3
5862
by: ggftw | last post by:
Hi, I have 2 forms named frmProdSearchCat and frmProdSearchMaxPrice. They allow the user to search for several products based on the category and their budget respectively. I have a report named...
1
1358
by: sroseindy | last post by:
PLEASE HELP - I NEED THIS TO COMPLETE A CONTRACT!!! Hi all, I have a report based on a crosstab query. The number of columns is dynamic based on the selection criteria the user chooses. I’ve set up...
0
6908
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7044
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7084
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6739
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6929
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
2995
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
563
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
181
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.