If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Shrink font size for select records
Hi there,
I've been looking for threads about shrinking text to fit a control (rather than allowing control to grow). I looked on Lebans' site but could not figure out how to import his fTextWidth module to my own database. (Also could not understand his instructions well enough to use them in a report rather than a form, which is what his solutions were designed for.) The solution I arrived at is not the most elegant one, but given that it's a small number of records that are not fitting in the control, it seemed like the most expedient. When I tried shrinking text strings that were above a certain number of characters, some records were shrunk unnecessarily. Okay, so here's what I wrote for the Format Event in the Detail section, and it works fine, except that when I try to close and save the report, I get an error message: Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer) If Me.Shareholder Like "Quattrociocchi*" Or Me.Shareholder Like "Moore August*" Or Me.Shareholder Like "MacDonald August*" Then Me.Shareholder.FontSize = 7 Else Me.Shareholder.FontSize = 8 End If End Sub The error message is: "The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. (Error 3022)" I have no idea what this means. I can't figure out where there would be duplicate values, although the underlying query for this report does rest upon a field called "Full Name" and another called "FullName," which is renamed "Shareholder" for the purposes of this report. Can you help me to debug? Thank you in advance! |
#2
|
|||
|
|||
Shrink font size for select records
Hi Laura,
The only thing I can think it would be complaining about is that it cannot save the report, as opposed to saving data. Saving data into a table does not make any sense with a report. Unless there is other code with the report that writes information into a table. So it could well be corruption of the database. Make a copy of the database first just in case something further happens. Then do a compact and repair. Does that help? If not, you might want to create a new database and import all of the objects from the existing one into the new one. Does that make a difference? On the other subject, of changing font size, here is a pretty simple (untested) solution. Add to the appropriate table a field named something like "Name_Font_Size". For those records where there is a long name, add the appropriate value (7, or maybe even 6) to the field. For all others leave them blank. Include that field in your report's query. Then in your detail's On Format event do one line: Shareholder.FontSize = Nz(Name_Font_Size, 8) This will use the default size of 8 when there is no size specified, otherwise it will use the specified size. You may need to add the Name_Font_Size field to the report's detail section in order to get this to work. If so, just make it invisible. Hope that helps, Clifford Bass "Laura C." wrote: Hi there, I've been looking for threads about shrinking text to fit a control (rather than allowing control to grow). I looked on Lebans' site but could not figure out how to import his fTextWidth module to my own database. (Also could not understand his instructions well enough to use them in a report rather than a form, which is what his solutions were designed for.) The solution I arrived at is not the most elegant one, but given that it's a small number of records that are not fitting in the control, it seemed like the most expedient. When I tried shrinking text strings that were above a certain number of characters, some records were shrunk unnecessarily. Okay, so here's what I wrote for the Format Event in the Detail section, and it works fine, except that when I try to close and save the report, I get an error message: Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer) If Me.Shareholder Like "Quattrociocchi*" Or Me.Shareholder Like "Moore August*" Or Me.Shareholder Like "MacDonald August*" Then Me.Shareholder.FontSize = 7 Else Me.Shareholder.FontSize = 8 End If End Sub The error message is: "The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. (Error 3022)" I have no idea what this means. I can't figure out where there would be duplicate values, although the underlying query for this report does rest upon a field called "Full Name" and another called "FullName," which is renamed "Shareholder" for the purposes of this report. Can you help me to debug? Thank you in advance! |
Thread Tools | |
Display Modes | |
|
|