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!

Visible/Non-Visible Objects on Form 4

Status
Not open for further replies.

gRegulator

Technical User
Jul 3, 2003
133
CA
Hi,

I have a form (form1) which contains a combo box (cboClinic). When a particular clinic is selected from cboclinic, i would like to display a series of text boxes relating to each one for data entry. For example, if "Dermatology" is selected in the combo box, i would like to make all the particulars relating to dermatology visible, or if "Adult Cardiology" is selected I would like to make the Adult Cardiology related text boxes visible, etc. The reason why I would like to do this is because I have one large Master Table which all data is entered into, and from that, it is seperated into queries. This would just cut down on a lot of clutter, and make it much easier for the data entry person. I hope this makes sense. I appreciate any help I can get! Thanks guys!

Greg
 
Try using the onChange event for cboClinic.

If Forms![Form1]![cboClinic] = 1 Then
ctrl_1.Visible = True
ctrl_2.Visible = True
...
Else If Forms![Form1]![cboClinic] = 2 Then
ctrl_3.Visible = True
ctrl_4.Visible = True
...


get the idea? A switch statement could be used too.
 
I believe you have a few options available to you here, trouble is all will probably end up with a lot of work.

You could
1) Have one Tabbed form with a Tab for each 'medical department' thus only putting the required fields on each tab. This would be OK for up to 10 departments and then it gets messy.

or
2) Once the department is selected in the combo,have a separate form open with only relevant fields. (multiple forms)
or
3) Once the department is selected in the combo, make all non relavent fields invisible, this however usually ends up with odd fields scattered around your form which looks yuk

It really depends on how many departments you have and how many relevant fields are attached to each.

I'm sure other forum readers will have some ideas too.

PassingBy
 
Okay,

I am working on the codes you suggested jason, I'll let you know how it goes, thanks for the advice.

PassingBy,
The second option you suggested was what I had originally wished to do. I was able to use the following code to open the form selected in the combo box, but I am totally lost on how to synchronize the forms. When I was trying to do it before, they would work, but enter as seperate records. This may have something to do with the fact that the forms open as Add only? I'm not too sure. Anyway, here is the code I was using, please offer suggestions as to how i can make them enter into the same record :)

Private Sub cboClinic_AfterUpdate()
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = Me.cboClinic.Value

stLinkCriteria = "[ID]= " & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub

This opened the desired form, and I couldn't quite get the synchronization to work.

I appreciate all your help guys!


 
Jason,

When using your codes, I encountered a slight problem. If I select a clinic, then select another one, the previous selection (that I just made visible) doesn't disappear. How can I do this? Thanks.
 
Hi,

Use following DoCmd to allow user to open form in Add Mode and acDialog will open a form in Dialog mode so, user have to close the current form to go back on main form where he came from.


DoCmd.OpenForm "Form1", , , stLinkCriteria, acFormAdd, acDialog




Hope this helps... :)
Hasu
(Trust on someone, someone will trust you!)
 
Jason, One more thing....The controls are remaining visible even after the record is entered and a new one is started.
 
Hey, First of all invisible all of your controls that you are displaying dynamically according to combobox value.

in the onChange event for cboClinic.

ctrl_1.Visible = false
ctrl_2.Visible = false
ctrl_3.Visible = false
ctrl_4.Visible = false
and so on ...

If Forms![Form1]![cboClinic] = 1 Then
ctrl_1.Visible = True
ctrl_2.Visible = True
...
Else If Forms![Form1]![cboClinic] = 2 Then
ctrl_3.Visible = True
ctrl_4.Visible = True
...



Hope this helps... :)
Hasu
(Trust on someone, someone will trust you!)
 
Hasu, Thanks alot for the tip! It worked very well. The only problem was that the visible control remained visible when moving to a new record. I solved this by adding a macro to submit the information, then close and reopen the form in add mode. So it all worked out fine! Thanks for your help everyone. Have a great day!

Greg
 
Thank for the star, Greg! That's my first one!
Great day to you.

Hope this helps... :)
Hasu
(Trust on someone, someone will trust you!)
 
No macros needed:

Case Select Me.Combo.Value
Case "Dermatology"
Me.Field1.Visible = True
Me.Field2.Visible = True
Case Else
Me.Field1.Visible = False
Me.Field2.Visible = False

Case "Other Options"
Me.Field3.Visible = True
Me.Field4.Visible = True
Case Else
Me.Field3.Visible = False
Me.Field4.Visible = False
End Select

Make all your fields set to invisible. Put this code on your On Click Event of the combo box, On load event of the Form and on current event of your form.

This way you only see the fields that pretain to the selection in your combo box and also when you move between the records the proper fields show up.

You could also use If - Then instead of Case Select but the idea is the same.

:)WB
 
wabeg you're awesome! Thanks for the advice. I really appreciate all the help!

Greg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top