Solved DatasheetFontName

KitaYama

Well-known member
Local time
Today, 09:19
Joined
Jan 6, 2022
Messages
1,775
When I do a SaveAsText on any form, the text file contains the following three lines:

RecordSource ="....."
Caption ="....."
DatasheetFontName ="....."

I can't find a DatasheetFontName is property sheet of the form. Is there anyplace I can change it manually?

Extra question:
When I add a new control in a form, Access/Windows selects a specific font for this control. Is there anyway to change this default font?
(Registery, Windows setting, .......)


Thanks.
 
Last edited:
you can edit the default font of the datasheet, example:
on Form's Load event:
Code:
Private Sub Form_Load()
Me.DatasheetFontName = "Arial"
End Sub

for the fort, chatgpt answers:

Setting Default Font for New Controls​

If you want all new controls added to a form or report to have a specific font, you'll need to set the font properties manually for the first control, and then Access will use that font for subsequent controls.

Unfortunately, VBA doesn't provide a direct way to globally change the default font for all new forms and controls. For such custom settings, you'd typically set up a template form or report with the desired font settings and copy that template whenever you need a new form or report.
 
you can edit the default font of the datasheet, example:
on Form's Load event:
Code:
Private Sub Form_Load()
Me.DatasheetFontName = "Arial"
End Sub
@arnelgp Thanks but I have some troubles:

This one doesn't change the font:
SQL:
Sub test()
    DoCmd.OpenForm "frm"
    Forms("frm").DatasheetFontName = "Tahoma"
    DoCmd.Close acForm, "frm", acSaveYes
    SaveAsText acForm, "frm", "D:\frm.txt"
End Sub

Failing in above, I opened the "frm" form in design view, added a button and added this:
SQL:
Private Sub Command5_Click()
    Forms("frm").DatasheetFontName = "tahoma"
    DoCmd.Close acForm, Me.Name, acSaveYes
End Sub
I Changed the font and executed : SaveAsText acForm, "frm", "D:\frm.txt" (From immediate window)
Only 8 or 10 times out of 40 or 50 tests was effective.
I couldn't find a specific workflow when it works and when it doesn't.

Any idea?


In case of second part, unfortunately it doesn't work how chatGPT explains. I added an empty form, add a textbox, in the wizard changed the font and finished the wizard. Closed and saved from. Then I opened it in design mode and added another textbox. The font was not as the first control.
Thanks again.
 
Last edited:
Couple of thoughts:

- when in datasheet view, change the font on ribbon , then save the form

- check the form property for default view=datasheet

Perhaps also restrict the allowed views
 
when in datasheet view, change the font on ribbon , then save the form
10 tests , 10 successes.
Seems that it's the way to go.

Do you have any idea for my extra question too?
Thanks.
 
not sure what your other question is?
Is there anyway to change this default font Access uses for new controls?

would form templates for you?
I didn't know the template works for different databases on the same PC.
So I had given up on temaplate.
Will read the article and give it a try.

Thanks.
For now, I think I have the answer to my question.
 
Is there anyway to change this default font Access uses for new controls?
Have you tried?
  1. Opening a form in design view
  2. Select the textbox control from the ribbon but don't add it to the form yet
  3. Go to the properties window and change the font name to the one you want
  4. Now you can add the textbox to the form and check the font
 
Have you tried?
  1. Opening a form in design view
  2. Select the textbox control from the ribbon but don't add it to the form yet
  3. Go to the properties window and change the font name to the one you want
  4. Now you can add the textbox to the form and check the font
Thanks. I'm away from Access now. Will give it a try and see how it goes. (7 hours from now)
 
you can set a template in options>object Designers>Form/Report design view.

There is also the application parts on the ribbon (although I've not used it)
 
you can set a template in options>object Designers>Form/Report design view.
All these years with Access and I don't know why I thought that option belongs to current database.
I'll give it a try too.

thanks.
 
@theDBguy Checked. And it's perfect. Thanks.
@isladogs Thanks for the excellent step by step article. But as you mentioned in the article too, this method (and what the @theDBguy explained) changes the defaults for current form. Once the form is closed and I want to work on a new/another form, everything is reset. It seems that there's no/few privileges over my current work flow. (copy/pasting an existing control).

Unless I save it as a default template. (As explained in article and suggested by @CJ_London.)

I really appreciate all given advices. Now I have a template form with my preferred properties.
I think all my questions in this case are answered.
Million thanks for your help and time.

Cheers.
 

Users who are viewing this thread

Back
Top Bottom