Modifying report Fonts etc., in preceeding form

I'm getting a compile error on Module 1 saying: 'Only comments may appear after End Sub, End Function, End Property' on the line:
Declare PtrSafe Sub wlib_AccColorDialog _
Lib "msaccess.exe" _
Alias "#53" (ByVal Hwnd As LongPtr, lngRGB As LongPtr)



Not sure why that is?
 
I'm not getting that on my 32 bit Office system. Below is what my entire module looks like now. Is yours the same.
Code:
Option Compare Database
Option Explicit

Declare PtrSafe Sub wlib_AccColorDialog _
Lib "msaccess.exe" _
Alias "#53" (ByVal Hwnd As LongPtr, lngRGB As LongPtr)



Public Function ChooseWebColor(DefaultWebColor As Variant) As String
  Dim lngColor As Long
  lngColor = CLng("&H" & Right("000000" + _
                  Replace(Nz(DefaultWebColor, ""), "#", ""), 6))
  wlib_AccColorDialog Screen.ActiveForm.Hwnd, lngColor
  ChooseWebColor = "#" & Right("000000" & Hex(lngColor), 6)
End Function
 
I have this in Module 1 as well:
Public Sub ChangeReportProperties(strReportName, strFontName, strFontSize)

DoCmd.OpenReport strReportName, acViewDesign
Reports.Item(strReportName)![Text1].FontName = strFontName
Reports.Item(strReportName)![Text1].FontSize = strFontSize
DoCmd.Close acReport, strReportName, acSaveYes

End Sub
and also you test sub, which I removed.

Now opens form OK, but errors on this:
'ByRef argument type mismatch' on the word 'lngColor'

 
Right!
The sub routine I removed needs to go somewhere and not the Module.

I have lost track of where it needs to go, luckily I copied it to Word.
 
I have this in Module 1 as well:
Public Sub ChangeReportProperties(strReportName, strFontName, strFontSize)

DoCmd.OpenReport strReportName, acViewDesign
Reports.Item(strReportName)![Text1].FontName = strFontName
Reports.Item(strReportName)![Text1].FontSize = strFontSize
DoCmd.Close acReport, strReportName, acSaveYes

End Sub
and also you test sub, which I removed.

Now opens form OK, but errors on this:
'ByRef argument type mismatch' on the word 'lngColor'


I've been putting that subroutine in the Frm_Verses_mstr module but that shouldn't make any difference. I don't know where you are in this installation so I can't comment on the specific error you are getting now

I suggest getting the database I sent you working by putting in the ptrSafe stuff and then try to see what the differences between your database and the one I sent you are.

I need a nap now. I'll be back on line in a couple of hours.
 
All sorted!

Put sub-routine back into module, but had to add, the new argument for the color:
Public Sub ChangeReportProperties(strReportName, strFontName, strFontSize, strForeColor)

DoCmd.OpenReport strReportName, acViewDesign
Reports.Item(strReportName)![Text1].FontName = strFontName
Reports.Item(strReportName)![Text1].FontSize = strFontSize
Reports.Item(strReportName)![Text1].ForeColor = strForeColor

DoCmd.Close acReport, strReportName, acSaveYes

End Sub

Thank you for all of your help. I would have given up without your help!
 

Users who are viewing this thread

Back
Top Bottom