Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Code to Change Color of Box based on Yes/No 1

Status
Not open for further replies.

ve7epq

Technical User
Dec 17, 2003
25
CA
Access 2000 and VBA

I have a series of forms in my Database. I have my main form (FORM1) and on the bottom of it I have rectangles with text in them and an "on click" event that takes me to (FORM2) or (FORM3) etc. I come back from each form to my main form. Once input is complete on (FORM2) I have a check box (Yes/No) for done. I want to then change the background color of the Box1 (Box2) etc. to grey. That way my user can see at a glance how many of the forms that pertain to the complete database have been done without looking through each FORM to see. I understand the basic principle of the number codes, but I want to do something like...

if FORM2!CheckBox1 = Yes Then
FORM1!Box1.backcolor = 12632256
else endif

Now that is a guess. What little I did playing with it didnt work so far. Where would I put the code....I was thinking it should be in the "on click" button that sends me "back" from FORM2 to FORM1.

I have searched the thread and havent stumbled on an answer. Any help would be greatly appreciated.

Mike
 
Yes, you put the code in the OnClick, after the line where you show the form2 modally.
Once form2 closes, your coloring code is called.

 
I am sorry, but I am not familiar with the term "modally". The on-click event is a docmd.close Is the code correct as well?

Mike
 
The line in Form1 looks like this

Docmd.OpenForm etc.

If FORMS......


When the call returns from FORM2 it does not even execute the IF THEN statements (did a debug check and it didnt run them)....so I am not sure where to place the code now.

I really appreciate the help

Mike
 
>>The line in Form1 looks like this
Docmd.OpenForm etc.
If FORMS......<<

Sorry, I should have been more clear - it is indeed the OnClick in the Form1 that should contain the code.

I am confused as to why the IF THEN does not get executed.

Modally means 'all processing stops until the form is closed.'

The normal VBA syntax for this is Form2.show vbmodal, although I am not 100% that this is accurate for Access.
(Try it, and search the Vb help for 'modal')

Normal construct is:

Form2.show vbmodal
If thing then
'do stuff
end if

Try putting a message box in after showing the Form2...



 
Thanks for the valiant effort. I have decided to continue on the database development and come back later to the &quot;back.color box&quot; question. I have to get this out for my clients use and I am going to have to live with it not doing that right away. Silly MS not allowing us to change the back.color of a command button in Access 2000.

I am going to have to do some coding just playing around, to learn how to do it properly. Will post that when it works. :-}

Mike Donovan
 
Opening a form in dialog mode:

[tt]docmd.openform &quot;yourform&quot;,,,,,acDialog[/tt]

In stead of using a command button, try using a label, as in the end of this thread thread702-761130.

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top