ARGUMENT NOT OPTIONAL error on font dialog

R_McCallan

New Member
Joined
Aug 17, 2010
Messages
9
I have recently create a font dialogue which passes values into text boxes on a form. I made font name and size work but font style (bold etc) will not work! I think this is because style is more complex as it has weight, italic and underline as controls. Anyway. Upon clicking the macro which opens the font dialogue, this error appears 'Compile error: Argument not optional.' Below is my code. cmdFP AND cmdFP2,3 and 4 are the command buttons which should open the font dialogue on click (there are 4 because I want to edit headers, footers, text boxes and labels)

Code:
 Option Compare Database
Option Explicit
Private Sub cmdFinish_Click()
DoCmd.Close acForm, "frm000_fontpicker", acSaveYes
End Sub

Private Sub cmdFP_Click()
Dim lngRet As Boolean
    lngRet = test_DialogFont(Me.txtHeaderFont, Me.txtheadersize, Me.txtheaderstyle)
End Sub

Private Sub cmdFP2_Click()
Dim lngRet As Boolean
    lngRet = test_DialogFont(Me.txtFooterFont, Me.txtfootersize, Me.txtfooterstyle)
End Sub

Private Sub cmdFP3_Click()
Dim lngRet As Boolean
    lngRet = test_DialogFont(Me.txtDatafieldsFont, Me.txtdatafieldsize, Me.txtdatafieldstyle)
End Sub

Private Sub cmdFP4_Click()
Dim lngRet As Boolean
    lngRet = test_DialogFont(Me.txtLabelsFont, Me.txtlabelsize, Me.txtlabelstyle)
End Sub

Private Sub cmdPreview_Click()

On Error GoTo Err_funErrorChecking
Dim ctr As Container
Dim doc As Document
Dim db As Database
Dim ctl As Control

Set db = CurrentDb
Set ctr = db.Containers!Forms

Me.txtHeaderFont.FontName = Me.txtDatafieldsFont
Me.txtHeaderFont.FontSize = Me.txtdatafieldsize
Me.txtheadersize.FontSize = Me.txtdatafieldsize
Me.txtheadersize.FontName = Me.txtDatafieldsFont
Me.txtheaderstyle.FontName = Me.txtDatafieldsFont
Me.txtheaderstyle.FontSize = Me.txtdatafieldsize
Me.txtHeaderFont.FontBold = Me.txtdatafieldstyle
Me.txtheadersize.FontBold = Me.txtdatafieldstyle
Me.txtheaderstyle.FontBold = Me.txtdatafieldstyle
Me.txtHeaderFont.FontUnderline = Me.txtdatafieldstyle
Me.txtheadersize.FontUnderline = Me.txtdatafieldstyle
Me.txtheaderstyle.FontUnderline = Me.txtdatafieldstyle
Me.txtHeaderFont.FontItalic = Me.txtdatafieldstyle
Me.txtheadersize.FontItalic = Me.txtdatafieldstyle
Me.txtheaderstyle.FontItalic = Me.txtdatafieldstyle

Me.txtFooterFont.FontName = Me.txtDatafieldsFont
Me.txtFooterFont.FontSize = Me.txtdatafieldsize
Me.txtfootersize.FontSize = Me.txtdatafieldsize
Me.txtfootersize.FontName = Me.txtDatafieldsFont
Me.txtfooterstyle.FontName = Me.txtDatafieldsFont
Me.txtfooterstyle.FontSize = Me.txtdatafieldsize
Me.txtFooterFont.FontBold = Me.txtdatafieldstyle
Me.txtfootersize.FontBold = Me.txtdatafieldstyle
Me.txtfooterstyle.FontBold = Me.txtdatafieldstyle
Me.txtFooterFont.FontUnderline = Me.txtdatafieldstyle
Me.txtfootersize.FontUnderline = Me.txtdatafieldstyle
Me.txtfooterstyle.FontUnderline = Me.txtdatafieldstyle
Me.txtFooterFont.FontItalic = Me.txtdatafieldstyle
Me.txtfootersize.FontItalic = Me.txtdatafieldstyle
Me.txtfooterstyle.FontItalic = Me.txtdatafieldstyle

Me.txtDatafieldsFont.FontName = Me.txtDatafieldsFont
Me.txtDatafieldsFont.FontSize = Me.txtdatafieldsize
Me.txtdatafieldsize.FontSize = Me.txtdatafieldsize
Me.txtdatafieldsize.FontName = Me.txtDatafieldsFont
Me.txtdatafieldstyle.FontName = Me.txtDatafieldsFont
Me.txtdatafieldstyle.FontSize = Me.txtdatafieldsize
Me.txtDatafieldsFont.FontBold = Me.txtdatafieldstyle
Me.txtdatafieldsize.FontBold = Me.txtdatafieldstyle
Me.txtdatafieldstyle.FontBold = Me.txtdatafieldstyle
Me.txtDatafieldsFont.FontUnderline = Me.txtdatafieldstyle
Me.txtdatafieldsize.FontUnderline = Me.txtdatafieldstyle
Me.txtdatafieldstyle.FontUnderline = Me.txtdatafieldstyle
Me.txtDatafieldsFont.FontItalic = Me.txtdatafieldstyle
Me.txtdatafieldsize.FontItalic = Me.txtdatafieldstyle
Me.txtdatafieldstyle.FontItalic = Me.txtdatafieldstyle

Me.txtLabelsFont.FontName = Me.txtDatafieldsFont
Me.txtLabelsFont.FontSize = Me.txtdatafieldsize
Me.txtlabelsize.FontSize = Me.txtdatafieldsize
Me.txtlabelsize.FontName = Me.txtDatafieldsFont
Me.txtlabelstyle.FontName = Me.txtDatafieldsFont
Me.txtlabelstyle.FontSize = Me.txtdatafieldsize
Me.txtLabelsFont.FontBold = Me.txtdatafieldstyle
Me.txtlabelsize.FontBold = Me.txtdatafieldstyle
Me.txtlabelstyle.FontBold = Me.txtdatafieldstyle
Me.txtLabelsFont.FontUnderline = Me.txtdatafieldstyle
Me.txtlabelsize.FontUnderline = Me.txtdatafieldstyle
Me.txtlabelstyle.FontUnderline = Me.txtdatafieldstyle
Me.txtLabelsFont.FontItalic = Me.txtdatafieldstyle
Me.txtlabelsize.FontItalic = Me.txtdatafieldstyle
Me.txtlabelstyle.FontItalic = Me.txtdatafieldstyle

Me.Label24.FontName = Me.txtLabelsFont
Me.Label24.FontSize = Me.txtlabelsize
Me.Label24.FontSize = Me.txtlabelsize
Me.Label24.FontName = Me.txtLabelsFont
Me.Label24.FontName = Me.txtLabelsFont
Me.Label24.FontSize = Me.txtlabelsize
Me.Label24.FontBold = Me.txtlabelstyle
Me.Label24.FontBold = Me.txtlabelstyle
Me.Label24.FontBold = Me.txtlabelstyle
Me.Label24.FontUnderline = Me.txtlabelstyle
Me.Label24.FontUnderline = Me.txtlabelstyle
Me.Label24.FontUnderline = Me.txtlabelstyle
Me.Label24.FontItalic = Me.txtlabelstyle
Me.Label24.FontItalic = Me.txtlabelstyle
Me.Label24.FontItalic = Me.txtlabelstyle

Me.Label27.FontName = Me.txtLabelsFont
Me.Label27.FontSize = Me.txtlabelsize
Me.Label27.FontSize = Me.txtlabelsize
Me.Label27.FontName = Me.txtLabelsFont
Me.Label27.FontName = Me.txtLabelsFont
Me.Label27.FontSize = Me.txtlabelsize
Me.Label27.FontBold = Me.txtlabelstyle
Me.Label27.FontBold = Me.txtlabelstyle
Me.Label27.FontBold = Me.txtlabelstyle
Me.Label27.FontUnderline = Me.txtlabelstyle
Me.Label27.FontUnderline = Me.txtlabelstyle
Me.Label27.FontUnderline = Me.txtlabelstyle
Me.Label27.FontItalic = Me.txtlabelstyle
Me.Label27.FontItalic = Me.txtlabelstyle
Me.Label27.FontItalic = Me.txtlabelstyle

Me.Label13.FontName = Me.txtLabelsFont
Me.Label13.FontSize = Me.txtlabelsize
Me.Label13.FontSize = Me.txtlabelsize
Me.Label13.FontName = Me.txtLabelsFont
Me.Label13.FontName = Me.txtLabelsFont
Me.Label13.FontSize = Me.txtlabelsize
Me.Label13.FontBold = Me.txtlabelstyle
Me.Label13.FontBold = Me.txtlabelstyle
Me.Label13.FontBold = Me.txtlabelstyle
Me.Label13.FontUnderline = Me.txtlabelstyle
Me.Label13.FontUnderline = Me.txtlabelstyle
Me.Label13.FontUnderline = Me.txtlabelstyle
Me.Label13.FontItalic = Me.txtlabelstyle
Me.Label13.FontItalic = Me.txtlabelstyle
Me.Label13.FontItalic = Me.txtlabelstyle

Me.Label16.FontName = Me.txtLabelsFont
Me.Label16.FontSize = Me.txtlabelsize
Me.Label16.FontSize = Me.txtlabelsize
Me.Label16.FontName = Me.txtLabelsFont
Me.Label16.FontName = Me.txtLabelsFont
Me.Label16.FontSize = Me.txtlabelsize
Me.Label16.FontBold = Me.txtlabelstyle
Me.Label16.FontBold = Me.txtlabelstyle
Me.Label16.FontBold = Me.txtlabelstyle
Me.Label16.FontUnderline = Me.txtlabelstyle
Me.Label16.FontUnderline = Me.txtlabelstyle
Me.Label16.FontUnderline = Me.txtlabelstyle
Me.Label16.FontItalic = Me.txtlabelstyle
Me.Label16.FontItalic = Me.txtlabelstyle
Me.Label16.FontItalic = Me.txtlabelstyle

Me.Controls("lblHeader").FontName = Me.txtHeaderFont
Me.Controls("lblheader").FontSize = Me.txtheadersize
Me.Controls("lblFooter").FontName = Me.txtFooterFont
Me.Controls("lblfooter").FontSize = Me.txtfootersize
Me.Controls("lblheader").FontStyle = Me.txtheaderstyle
Me.Controls("lblFooter").FontStyle = Me.txtfooterstyle

Exit_funErrorChecking:
    Exit Sub
    
Err_funErrorChecking:
    Select Case Err.Number
    Case 2462
        Resume Next
    Case 2465
        Resume Next
    Case Else
        Call funErrorChecking(Err.Description, Err.Number, Application.CurrentObjectName, "frm000_colorpicker")
        Resume Exit_funErrorChecking
        Resume
    End Select

End Sub

Private Sub cmdReset_Click()

txtHeaderFont = Null
txtFooterFont = Null
txtDatafieldsFont = Null
txtLabelsFont = Null
txtheadersize = Null
txtfootersize = Null
txtdatafieldsize = Null
txtlabelsize = Null
txtheaderstyle = Null
txtfooterstyle = Null
txtdatafieldstyle = Null
txtlabelstyle = Null

End Sub

Private Sub cmdRun_Click()

Call funChangeFontStyle

End Sub
Any help is appreciated!

Thanks,

Rebecca :biggrin:
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,223,763
Messages
6,174,359
Members
452,558
Latest member
jswan83

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top