DataSheetForeColor

J

JamesJ

I'm attempting to set the Datasheet font color for my split form(s) in AC
2007
I'm able to set other properties such as DataSheetFontName and
DataSheetBackColor
with no errors but for frm.DatasheetForeColor = RGB(240, 255, 255)
generates the following error:

Runtime Error 2101
The setting you entered isn't valid for this property.

Public Function DataSheetFont(frm As Form)

frm.DatasheetFontName = "Calibri"
frm.DatasheetFontHeight = 12
frm.DatasheetBackColor = RGB(72, 118, 255)
frm.DatasheetAlternateBackColor = RGB(0, 0, 238)
frm.DatasheetGridlinesColor = RGB(202, 225, 255)
frm.DatasheetForeColor = RGB(240, 255, 255)

End Function
 
M

Mr B

JamesJ,

From the VBA Help file about several of the properties of a form with the
devault view set to datasheet: "you can add them in an Access database (.mdb)
by using the CreateProperty method and append it to the DAO Properties
collection"

When you are looking at your VBA code, place your cursor in the
"DatasheetForeColor" statement. Press F1 and take a look at the method for
adding these properties to the forms DAO properties.
 
J

JamesJ

One question, though.
When typing in the line in the debug window the auto list selection box
(I believe that's what it is refered to as) opens and the properety
(DataSheetForeColor) is in the auto list. This tells me the property is
already available, same as all the other DataSheet properties that I set in
the code.
Am I correct ?
I'm trying to understand this.

James
 
M

Mr B

JamesJ,

You are correct. The help file reference actually is refering to the
setting of the properties for a table not a form. My mistake.

I have copied you code exactly and tested your function and it works for me,
exactly as you have it when I call the function from the OnCurrent event of
the split form like this:

DataSheetFont Forms!NameOfYourForm

I realize that you are using this function, and that is a very appropriate
method for doing what you are trying to do, especially if you are needing to
apply the same formatting to multiple forms. However, if you are only
wanting to apply this formatting to a single form you have the option of
doing this same thing using code like this:

Me.DatasheetFontName = "Calibri"
Me.DatasheetFontHeight = 12
Me.DatasheetBackColor = RGB(72, 118, 255)
Me.DatasheetAlternateBackColor = RGB(0, 0, 238)
Me.DatasheetGridlinesColor = RGB(202, 225, 255)
Me.DatasheetForeColor = RGB(240, 255, 255)

Hopefully some of this has helped you a little bit.

Sorry, but I do not have anything else to offer on this one but I will be
following this thread to see how it turns out.
 
J

JamesJ

It works fine from the OnCurrent of the form.
That's fine calling it from the OnCurrent, I was calling the function
from the OnOpen of the form. Don't know why I was getting
the error message from the OnOpen.

Thanks,
James
 
M

Mr B

I am glad it is working for you now.

Sometime you just stumble on to the solution.

I have to assume that the Fore Color property cannot be set until after the
form is completely loaded. Anyway, the OnCurrent event is as good a place to
call the function as any.

Good luck with you project.

Mr B
askdoctoraccess dot com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top