Setting Forms Font (1 Viewer)

David44Coder

Member
Local time
Today, 17:47
Joined
May 20, 2022
Messages
110
I've used the Form Wizard to create my form then DesignMode-Format-SelectAll and selected a Font and size from Font area.
It changes to the one required.
But if I close the Form and open it from the Navigation pane it uses a different font.

How can it be altered so it sticks? The form uses Datasheet view.
 

David44Coder

Member
Local time
Today, 17:47
Joined
May 20, 2022
Messages
110
That is what I thought I'd done. Could you define the correct steps please?
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 22:47
Joined
Oct 29, 2018
Messages
21,542
Hi. Welcome to AWF!

When you closed the form, did it ask you to save your changes?
 

David44Coder

Member
Local time
Today, 17:47
Joined
May 20, 2022
Messages
110
Gee I think so. I have saved it several times since though. In design mode the controls reflect the font chosen, but when Opened at run time it is the font used by the system (Calibri). Yet some other Forms aren't using calibri. So all a but puzzling.
Thanks for the welcome :)
 

strive4peace

AWF VIP
Local time
Today, 00:47
Joined
Apr 3, 2020
Messages
1,002
hi @David44Coder

hmmm, I just looked in design view but its not available ... perhaps change in datasheet view and then change something in design view?

However, there's an option to set it -- then it will apply to all of your queries

1653374356907.png
 

David44Coder

Member
Local time
Today, 17:47
Joined
May 20, 2022
Messages
110
Thanks for the suggestion, although I didn't try it now. I'm adding to a db with existing forms that somehow have different fonts and I didn't want to risk changing them all and maybe losing their layouts. So I copied a Form that had the font I want, and replaced all it's controls. It took ages and I was conscious there must be some other way. So I'd still like to find the steps to change font on a datasheet Form, if anyone knows.
 

David44Coder

Member
Local time
Today, 17:47
Joined
May 20, 2022
Messages
110
Ah, I have figured it out.

Code:
Private Sub Form_Load()
    Me.DatasheetFontHeight = 9
    Me.DatasheetFontName = "Tahoma"
End Sub
I suspect the Ribbon or Design Mode is not what you use, even though it seems it should be. Maybe someone can expand on that?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 06:47
Joined
Feb 19, 2013
Messages
16,668
The form uses Datasheet view.

Data sheets have different properties to forms - other than conditional formatting, formatting applies to the whole sheet not individual controls. Same applies to height and width of columns
 

strive4peace

AWF VIP
Local time
Today, 00:47
Joined
Apr 3, 2020
Messages
1,002
@David44Coder -- glad you figured it out ~ sometimes asking questions and reading what others suggest helps you get it on your own!
 

David44Coder

Member
Local time
Today, 17:47
Joined
May 20, 2022
Messages
110
CJ, am I correct - datasheets properties can only be set in code ?
I ask because I appear to have some forms with varying fonts, but no corresponding code to set it up.
Suggesting there must be some other way.
Thanks Crystal, it's certainly working but I've a suspicion it's not the full story.
 

strive4peace

AWF VIP
Local time
Today, 00:47
Joined
Apr 3, 2020
Messages
1,002
@David44Coder, the only way I know to make things different for different columns on a Datasheet is to change colors via specifying the color you want in the Format code for a column. To set Format for a column, right-click in Design View and turn on Properties. Then click on what you want to set properties for. Access doesn't display which column you're in on the grid as you're setting properties in a query, so it can be easy to do the wrong one -- you'll see when you look at the datasheet view ;) In a form, however, the name of the control is displayed at the top of the property sheet.

on Format code for numbers, there are 4 parts:
1. format for positive numbers
2. format for negative numbers
3. format for 0 (zero)
4. format for null

each part is separated with ; semi-colon

this makes positive values green, negative values red, and zeros blue, and also specifies a comma to separate thousands, and to show 2 decimal places unless it's zero, in which case, it can look different to be easier to notice.
[green]#,##0.00;[red]-#,##0.00;[blue]-0-

for text, you can color the text blue using this:
[blue]@

Available colors:
Black, Blue, Green, Cyan, Red, Magenta, Yellow, White.
 
Last edited:

David44Coder

Member
Local time
Today, 17:47
Joined
May 20, 2022
Messages
110
Crystal, it isn't a different font per column wanted, but the same one for all columns. As you say design view doesn't show any columns. Just text box controls and their label controls. I did try changing some properties but it had no effect. Which one were you using?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 06:47
Joined
Feb 19, 2013
Messages
16,668
CJ, am I correct - datasheets properties can only be set in code ?
correct - other than setting the 'standard' properties per post#6

I ask because I appear to have some forms with varying fonts, but no corresponding code to set it up.
Suggesting there must be some other way.
perhaps the code is with the control that opens the form? Or perhaps it is actually a continuous form that has been designed to look like a datasheet. Or perhaps it is using conditional formatting?

In addition to Crystal's comments about the format datasheets will also display richtext formatting so if the fields in question are longtext you might be seeing richtext formatting

suggest provide some actual examples rather than a description
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 01:47
Joined
Feb 19, 2002
Messages
43,484
When your form is in DS view, Access has to ignore certain properties set on the form since ALL formatting for the controls must be consistent but there are certain things you can change when the form opens. Look for properties that start with "Datasheet".
Code:
Private Sub Form_Open(Cancel As Integer)
    'Me.DatasheetBackColor = 12574649
    Me.DatasheetBackColor = 13487510
    Me.DatasheetFontName = "Playbill"
    Me.DatasheetGridlinesColor = vbRed
    Me.DatasheetFontHeight = 14
End Sub

I used playbill since it is obviously different from other fonts so it is easy to see.
AccDatasheetProperties.JPG
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 01:47
Joined
Feb 19, 2002
Messages
43,484
Be careful though. I was just playing around and changed the alternate back color to yellow but when I removed the line of code, it didn't go back to what it was. I had to set it to the color i used at the beginning of the procedure, run it, and then comment out that line too.
 

David44Coder

Member
Local time
Today, 17:47
Joined
May 20, 2022
Messages
110
Thanks for the replies. Still digesting it all.. not easy as things do vary. For example I spent hours looking how to change the font (hence my initial question) because I knew I'd done it somehow and NOT in code, which contradicts what CJ said. ... but could not remember how. Now I have it again, Open datasheet Form, Home tab, Tex Formatting section and you can set a Font and Size. But this did not work in another form. I think the text formatting area was greyed out. I'm investigating.. there's a few others things, the caption bar looks different and the Form has a very thin red line around the outside. To Pat, I'll check that out and it looks a good way to do things.
This current db isn't something I created, I'm just modifying it.
 

strive4peace

AWF VIP
Local time
Today, 00:47
Joined
Apr 3, 2020
Messages
1,002
hi @David44Coder

if you've seen different fomatting, it's probably as @CJ_London said about Rich Text Long Text fields --or conditional formatting

Long Text is not stored like standard data types -- it's a pointer to something else, and using them can cause unexpected issues

> current db isn't something I created, I'm just modifying it

harder to modify than to do it yourself to begin with ~~ good luck!
 

CJ_London

Super Moderator
Staff member
Local time
Today, 06:47
Joined
Feb 19, 2013
Messages
16,668
At the risk of contradicting myself, If your subform is a datasheet then whilst in open view (not design) and you have access to the ribbon text formatting section under the Home tab, by clicking on the datasheet you can set the font etc. You then need to save to preserve the formatting.

If your subform is based on a datasheet form and you have applied the formatting to the query, that formatting will not be carried through to the form

Point is, this is all done in the open view, not design view. Also means it is not fully under your control and if you change things you may lose the formatting
 

Users who are viewing this thread

Top Bottom