Use combobox to set control properties?

faceman

Registered User.
Local time
Today, 19:34
Joined
Feb 11, 2003
Messages
20
I am creating a database to safety inspections. I start the inspection on form one. Then when i go to the 2nd form, there are a series of comboboxes with yes/no answers. What I am trying to accomplish is if I answer "no" to any of these comboboxes and click the button at the bottom of the form to go to form3, I want to set the appropriate fields there as required and make a red box around the text field visible. So to get down to my question... Can I use the result of a combobox on form2 to set control properties on form3?


Any help at all would be greatly appreciated.


Faceman
 
Yes you can, now how do you want to do it?
1> You can create global variables and set those how you wish in form2 to be checked in form3
2> You can open form3, and reference the values in form2 before you close form2 [Forms]![Form2]![fieldvalue]
3> You can use VBA/macro to setvalue in form3 from form2 during the switching process (timing issues here so be careful).
4> You can write the values from form2 to a table, and read them in form3
5> You can write a text file to the local drive in form2 and read it in form3 (OK not the best approach, but it can be done)

I usually use option 2 above, but if it is 1 or 2 values, I may use variables (either global or public)
 
RE: Using combobox to set control properties?

Fofa,
Could you please post an example of the code you would use for your preferred method?
I can't seem to get it to read the value of the combobox from form2. I even tried displaying the value into an unbound textbox on form3 which it does do, but when I try to use the text box to control the properties, it basically does the same thing as referencing the combox from form2. Nothing. I have tried the code in the onLoad, OnCurrent and onDirty with no avail.

I am familiar with Access, but am real new with VB so if you would be so kind as explain in simple terms, i would be thankful.
 
Can you attach your file file ? Are you using Access 97 ?:cool:
 
Combo Box Code

Form 1 = Partsfrm
Form 2 = Defectfrm


Form 2 combo box name = cmbFrame
(cmbFrame was made with the Wizard, pulling from a table with 3 records of 2 fields. 0 - Blank, 1 - Yes, 2 - No. With the results stored in the Table of tblParts.)

Form 3 Box to make visible = bxFrame

Button to do check and load Defectfrm = cmdNext


Private Sub cmdNext_Click()
On Error GoTo Err_cmdNext_Click

Docmd.OpenForm "Defectfrm"

If Forms!Partsfrm![cmbFrame] = "No" Then
Forms!Defectfrm![bxframe].visible = True
Else
Forms!Defectfrm![bxFrame].visible = False

End If

Docmd.Close

Exit_cmdNext_Click:
Exit Sub

Err_cmdNext_Click:
MsgBox Err.Description
Resume Exit_cmdNext_Click
End Sub



I have tried Forms!Partsfrm![cmbFrame].value = "No" Then....

But it does not work either. When I run the forms, I do not get any errors with the code, it just does not do anything. I have tried it with closing Form 2, hiding Form 2 and leaving Form 2 open behind Form 3. Nothing works. For some reason, I just can't seem to get it to read the combo box for the text of "Yes" or "No". I have gotten it to work using a macro as what was suggested, but it does not work as well as using code I don't think.

Does my code seem right so far?

Any thoughts or criticism is welcome.


Faceman
 
Last edited:

Users who are viewing this thread

Back
Top Bottom