Background 2 Color Gradient

A

Angeline

Hi,
I went searching in 'questions' to see how I can change the background
colour of my form to be more than just a solid colour. One of the threads
directed me to www.PetersSoftware.com where there is the option to download a
free MS database which explains how you can achieve a 2 colour gradient
through your form background. This is fanatasic but the problem is I am
stumped with the instructions which are very easy but because I am not a
programming, a simple instruction like "run the subroutine" does not make
sense to me. Even to "run" something to me basically means 'click on it'.

Hoping someone can help translate what steps I need to take. This is how far
I got:
"Import the Module "basBackColourGradient" from the ACCESS database
downloaded." This is fine, I got there okay. Here's where i get stumped:
" Run the sub-routine "bcg_CreateRectangles" for each form you want to add
a background colour gradient too".. THIS IS WHERE I'M STUMPED. What exact
steps do I need to take.

Then the last step is :
" Add the following sub-routine call to your forms OnOpen, OnActive event
procedure to set the back colour gradient bcg_setcolours Me '<Color1>,<Color2>
where <colour1> and <color2> are Windows system Color IDS, or MS Access
colour values. " ALSO STUMPED HERE. I know what the onopen, onactive event
procedure is but I'm not sure how exactly to set back colour gradient with
those instructions.

Really hope someone can help!

Angeline
SYDNEY
AUS
 
J

Jeff Conrad

Hi Angeline,

Sure, I can walk you through this.

1. Back-up your database.

2. Repeat Step 1 (don't make me come over there)

3. Create a new blank form as a "test" form called Form1.

4. Import the module basFormBackColorGradient from
the sample file. I think you have already done this.

5. Compile your code. Debug | Compile from the
menu bar in VBA Editor.

6. Open the Debug Window. Ctrl + G

7. Type this right into the window and hit Enter:
bcg_CreateRectangles "Form1",True
(replace the word true with False if you want a horizontal
gradient.)

8. A message box will appear warning you that changes
will be made to the form. Say Ok.

9. Now close the Dubg window and open the form in Design View.

10. Add the following code to the form's Open and Activate events:

Private Sub Form_Activate()
bcg_SetColors Me, 16711680, 8388736
End Sub

Private Sub Form_Open(Cancel As Integer)
bcg_SetColors Me, 16711680, 8388736
End Sub

11. Save and close the form. Then test. All should be good.

These are just sample colors to use. There are countless
ways to determine the specific number color you want,
but perhaps the easiest for you to do is open the sample
database and use the "Select Colors" form. Select a
couple of colors you like on that form and write down
the numbers. Then enter those numbers into the code
above.

Hope that helps,
--
Jeff Conrad
Access Junkie
Bend, Oregon

in message:
 
A

Angeline

Jeff,
YOU ARE FABULOUS!
Thank you very much. I did it and it worked! All I need to do now is choose
my colours and then add in then numbers! Thanks again and all the best!

Angeline
 
J

Jeff Conrad

in message:
Jeff,
YOU ARE FABULOUS!
Wow!

Thank you very much. I did it and it worked! All I need to do now is choose
my colours and then add in then numbers! Thanks again and all the best!

You're welcome, glad I could help.
:)
 
R

RosyCheeks :)

hey i am stuck in the same exact place you were but i followed the
instructions of the solution but still no hope :( i am really new to this i
don't understnad step 10. adding the code onactivate onopen how do you do
that can you tell me how you managed to get yours working please??????
 
A

Allan Murphy

I have used this coding using the following steps which may be some help to
you.

In the module basFormBackColorGradient there is a sub called Examples()

I changed the coding to the following line
bcg_CreateRectangles "frm_rpt_Courses", False
where frm_rpt_Courses is the name of the form.

With the cursor still in this sub I then pressed F5 various warning messages
were displayed and the detail section of the form had vertical rectangles

Then on Form_open event of the form I added the following code
bcg_SetColors Me, 15322008, 16711680

When the form is opened the background colour goes from a light blue
(15322008) to a dark blue.(16711680)
 
S

Stephen Lebans

Have you tried this solution?
http://www.lebans.com/gradientfill.htm
Updated June 8, 2004

A97GradientFill.zip is a database containing a function that demonstrates
how to enable Gradient Backgrounds for your Forms with a single function
call.

Version .8

Fixed two bugs brought to my attention by David Fenton. The one pixel black
border has been removed. Gradient fills now more logically starting from
left to right and top to bottom.

Version .7

Fixed runtime bug. Here is the modified Form Resize event code:

Private Sub Form_Resize()
' Call our function to redraw the Form's background Picture
' Access will generate a runtime error complaining
' that our image is not in the required DIB format
' even though it is if we:
'1) Minimize the form
'2) Shrink the form vertically below about 500 Twips
If Me.WindowHeight < 500 Then Exit Sub
GradientBackground Me, m_RGBStart, m_RGBEnd, m_Direction
End Sub

Version .6


--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
B

Billiam

Hi Rosy,

I, too, am new to all this and was stuck for a few weeks trying to get ths
to run. Eventually, i looked at the example file, and noticed they had placed
the event procedure code in the ON Activate and ON Deactivate fprm
properties. It now works. Anyone know why it didn't work placing the code in
the On Open property?

Billiam
 
B

Billiam

Hi Stephen,

I am new to Access and had some difficulty with step 10 of the background
gradient procedure. It turned out that placing the event procedure in the On
Open Form property would not run. When I opened your example form, I noticed
that the event procedures for these were in the On Activate and On Deactivate
procedure. When I placed the event in these areas of my form property
everything worked fine.

I am wondering why the gradient would not work on the ON Open procedure as
you call for. Does On Activate produce a call before On Open in Access 2007
vs '97 ???

Secondly, is it possible when using a header to have the gradient apply
there as well? Only the detail section of my form has the gradient and not
the Header portion.

Third, is it possible to have the gradient apply to each page of a tabbed
form?

Fourth, is there any way to stop the rectangles from becoming "selected"
when you are doing edits on your form? I tried to bring my fields and
controls to the front, but it does not seem to matter, you still seem to
inadvertently select the gradient rectangles every now and then.

Finally, thank you, thank you, SO MUCH for the procedure and help, it really
makes my form look "professional" even though I am NOT a professional, and it
really is very kind of you to help us newbies out!

Best Regards,

Billiam
 
B

Billiam

Sorry, 1 last question...I cannot seem to print the form after applying the
gradient...I know I can always produce a report, but it is very handy to just
allow my enduser to hit print. Is there a way to do this?
 

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