Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    ano is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Nov 2023
    Posts
    65

    datasheet font set in module

    i have main form "form1" containg subforms "form1a","form1b","form1c"
    i only like to use form1:load&unload calling module sub because forms are regenerated by wizard if too much trouble losing all
    preferable i loop through the subforms same like print property names from the subforms
    "" For Each ctl In frm.Controls Debug.Print ctl.Properties("Name") For Each prp In ctl.Properties
    Debug.Print vbTab & prp.Name & " = " & prp.Value Next prp Next ctl""
    so the next can be used on the subforms
    ""Public Sub ft(frm As Form, sm As String, sc As Integer, fn As String, fs As Integer)
    frm.DatasheetFontName = fn
    'Forms!form1.DatasheetFontSize = fs --> give error
    Forms!form1.DatasheetFontHeight = 8
    Forms!form1.DatasheetFontWeight = 500


    End Sub"" --> run without error but cannot find result

    end result wanted: size form & columns follow font ; yes i know column=-2 but that give ####
    i found a lot of related questions but never a good example or it was incomplete example

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,945
    Please post code between CODE tags.

    I don't even see a DatasheetFontSize property in Intellisense.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    ano is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Nov 2023
    Posts
    65
    dont understand code between code tags
    perhaps fontsize called height in datasheet?

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,444
    dont understand code between code tags
    - highlight your code and click the # button

    Code:
    Public Sub ft(frm As Form, sm As String, sc As Integer, fn As String, fs As Integer)
    frm.DatasheetFontName = fn
    'Forms!form1.DatasheetFontSize = fs --> give error
    Forms!form1.DatasheetFontHeight = 8
    Forms!form1.DatasheetFontWeight = 500
    End Sub
    FontSize is used in file>options>datasheet, in a datasheet form the equivalent is DatasheetFontHeight

  5. #5
    ano is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Nov 2023
    Posts
    65
    thnx for explaining
    yep guess its equivalent but not visible even no errors because i neede form1a,form1b,form1c other fonts , form1 is just thecontainer to combine 3 datasheets

  6. #6
    ano is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Nov 2023
    Posts
    65
    after many continue searching and trying i have add a toggle button above the forms in form1.
    bound font to toggle and na the screen look fine with fontsize 8-18 then it get overflow, but 18 is too large already.
    just amazed there is no default form resizing if use fontsize -2 , and not found how to measure the generated borders to align upper and lower form

  7. #7
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,444
    just amazed there is no default form resizing if use fontsize -2
    do you mean resize the column width? If so, you set the columnwidth property to -2, not the fontsize (and not coiumn per your first post

    not found how to measure the generated borders to align upper and lower form
    no idea what this means

  8. #8
    ano is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Nov 2023
    Posts
    65
    Quote Originally Posted by CJ_London View Post
    do you mean resize the column width? If so, you set the columnwidth property to -2, not the fontsize (and not coiumn per your first post

    no idea what this means
    sorry columnwidth i did mean and that should be cleat bec i refer to form resize
    if 2 forms beside each other under an other form like u see in the screenshot us see little diff in top form and under not much but not precise also bec there is some border that i did not find to control

  9. #9
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,444
    like u see in the screenshot
    I don't see a screenshot

  10. #10
    ano is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Nov 2023
    Posts
    65
    Click image for larger version. 

Name:	Screenshot 2024-05-01 220348.jpg 
Views:	11 
Size:	50.3 KB 
ID:	51759Click image for larger version. 

Name:	Screenshot 2024-05-01 092923.jpg 
Views:	12 
Size:	37.8 KB 
ID:	51758mmm dnt know why im sure i did upload it , i try againClick image for larger version. 

Name:	Screenshot 2024-05-01 092923.jpg 
Views:	12 
Size:	37.8 KB 
ID:	51758

  11. #11
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,444
    suggest rather than using a datasheet which has fewer design options, use a continuous form

  12. #12
    ano is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Nov 2023
    Posts
    65
    Quote Originally Posted by CJ_London View Post
    suggest rather than using a datasheet which has fewer design options, use a continuous form
    i read that often and many prefer datasheet

  13. #13
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,444
    Many who?

    If you want to use a datasheet for not what is intended you will have to live with the limitations of a datasheet since one of the benefits of a datasheet is the user can resize and reorder columns. One of the benefits of a continuous form is you can specify the width of each control and the user can't change it

    If you want to resize a control based on it's contents, that is doable, there are a number of examples out there.

    Only thing you can do is specify each column width by looping through the controls and specify them yourself. But there is nothing to stop the user then changing that.

    example air code


    Code:
    Forms!form1.DatasheetFontHeight = 8
    Forms!form1.DatasheetFontWeight = 500
    dim ctl as control
    for each ctl in Forms!form1.controls
         'resize to fit the contents
        If ctl.ControlType = acTextBox Then ctl.ColumnWidth = -2
        'or a common width
        'If ctl.ControlType = acTextBox Then ctl.ColumnWidth = 3000 '1440 twips =1 inch
    next ctl

  14. #14
    ano is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Nov 2023
    Posts
    65
    thnx for all effort just amazed that advice refer to form1 without datasheet . think next is more usefull :
    Code:
    Public Sub ft(frm1 As String, sm As String, f_s As Integer, fn As String, sc As Integer)
    Dim frms As Variant
    Dim frm As Variant
    Dim frm_frm As Form
    frms = Array("used", "saving", "bal_crosstab")
    For Each frm In frms
    Forms!form1!(frm).Form.DatasheetFontName = fn
    Forms!form1!(frm).Form.DatasheetFontHeight = f_s
    Forms!form1!(frm).Form.DatasheetFontWeight = 700
    Forms!form1!(frm).Form.RowHeight = f_s * 21 'not found what is best value
    Forms!form1!(frm).Form.DatasheetBackColor = vbYellow
    Forms!form1!(frm).Form.DatasheetForeColor = vbRed
    Select Case frm
    Case Is = "used"
    x(3) = Forms!form1!(frm).Form.RowHeight * 2.5 + 250 ' top subform
    Case Else 'both other subform
    x(8) = x(3)
    x(4) = x(3)
    End Select
    Next frm
    Forms!form1!(frm).Form.Recordset.MoveLast
    Forms!form1!(frm).Form.Recordset.MoveFirst
    x(7) = (Forms!form1!(frm).Form.Recordset.RecordCount + 1) * Forms!form1!(frm).Form.RowHeight + 800 'subform size
    x(11) = x(7)
    FrmLd True
    End Sub

  15. #15
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,980
    And still no code tags?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 13
    Last Post: 10-26-2019, 06:06 PM
  2. Replies: 12
    Last Post: 01-12-2019, 06:02 PM
  3. Replies: 4
    Last Post: 08-03-2014, 10:10 PM
  4. class module vs regular module
    By Madmax in forum Modules
    Replies: 1
    Last Post: 05-01-2012, 03:44 PM
  5. Replies: 4
    Last Post: 05-16-2011, 04:58 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums