Making controls visible on form if condition is met (1 Viewer)

SusanCB

Registered User.
Local time
Today, 05:02
Joined
Mar 10, 2010
Messages
34
Hi -- first of all, forgive me, I'm a librarian pretending to be a database programmer.

Hoping you can help me. I've got a form that allows users to pick a type of training from a Training Type combobox. If they pick "External," I want a "Cost of Training?" control to become visible.

I've been trying all kinds of code in the After Update box for the Training Type control, but nothing seems to make "Cost of Training?" become visible on the form.

Sorry if this is confusing -- you can only imagine what it's like in my brain! Thanks for any and all advice.
 

Mr. B

"Doctor Access"
Local time
Today, 04:02
Joined
May 20, 2009
Messages
1,932
What type of control is the "Cost of Training" control?

Is the After Update event of the "Training Cost" combo box firing?

Can you post the code you are already trying to use?
 

SusanCB

Registered User.
Local time
Today, 05:02
Joined
Mar 10, 2010
Messages
34
Thanks, Mr. B. I don't yet have the vocabulary to tell you what kind of control Cost of Training is, but it's a box that lets users enter the cost of a training.

This is my somewhat embarrassing attempt at writing an event procedure. I've put it in the AfterUpdate box (field? What's it called?) in the Training Type property sheet.

Private Sub Training_Type_AfterUpdate()
If Training_Type = "External" Then
Cost_of_Training.Visible = True
Else
Cost_of_Training.Visible = False
End Sub
 

missinglinq

AWF VIP
Local time
Today, 05:02
Joined
Jun 20, 2003
Messages
6,423
Also, importantly, is your form Single, Datasheet or Continuous Form View?

Linq ;0)>
 

Mr. B

"Doctor Access"
Local time
Today, 04:02
Joined
May 20, 2009
Messages
1,932
Are you sure that "Training_Type" and "Cost_of_Training" are the names of the controls on your form?

If so, try code like this:

Code:
Private Sub Training_Type_AfterUpdate()
If me.Training_Type = "External" Then 
[INDENT]Me.Cost_of_Training.Visible = True
[/INDENT]Else 
[INDENT]me.Cost_of_Training.Visible = False
[/INDENT]End Sub

The code above is only "air" code I have not tested it but it is really simplistic code and should work.

If adding the "Me." to the control identifications does not cause it to work, post back and try to tell us what happens if anything.
 

missinglinq

AWF VIP
Local time
Today, 05:02
Joined
Jun 20, 2003
Messages
6,423
Your code should work, making the minor modification suggested pf using Me.Training_Type. You will, however, also have to place it in the Form_Current event, in order for it to format correctly as you move from record to record.

Linq ;0)>
 

Mr. B

"Doctor Access"
Local time
Today, 04:02
Joined
May 20, 2009
Messages
1,932
Linq,

Good catch! I didn't think about that.
 

SusanCB

Registered User.
Local time
Today, 05:02
Joined
Mar 10, 2010
Messages
34
Urrgh, still not working. Here's the code exactly as I entered it (and yes, the control names are correct).

Private Sub Training_Type_AfterUpdate()

If Me.Training_Type = "External" Then
Me.Cost_of_Training.Visible = True
Else
Me.Cost_of_Training.Visible = False
End Sub


And here's how it looks in Form - On Current:

Private Sub Form_Current()

If Me.Training_Type = "External" Then
Me.Cost_of_Training.Visible = True
Else
Me.Cost_of_Training.Visible = False
End Sub


Any advice? Thanks so much -- I'm going nuts here.
 

Mr. B

"Doctor Access"
Local time
Today, 04:02
Joined
May 20, 2009
Messages
1,932
Can you attach a copy of your database file so we can see it and try to figure out what is going on?
 

SusanCB

Registered User.
Local time
Today, 05:02
Joined
Mar 10, 2010
Messages
34
Sure, here it is. Thanks so much again for your help and patience.
 

Attachments

  • CTPI-MKSEI Database - Copy.zip
    1.9 MB · Views: 471

missinglinq

AWF VIP
Local time
Today, 05:02
Joined
Jun 20, 2003
Messages
6,423
I can't open the file, as it's in 2007/2010 format, which raises the question; does any code work?

Code does not run in 2007/2010 unless your database resides in a folder that has been declared a “trusted” location.

To trust your folder, click:
  • Office Button (top left)
  • Access Options (bottom of dialog)
  • Trust Center (left)
  • Trust Center Settings (button)
  • Trusted Locations (left)
  • Add new location (button)
Here's a visual for it, courtesy of BTAB Development:

http://www.btabdevelopment.com/ts/default.aspx?PageId=13
 

SusanCB

Registered User.
Local time
Today, 05:02
Joined
Mar 10, 2010
Messages
34
YES!!!!! Changing the Trust Center settings totally did the trick. Thank you so, so, so much. Who knew it was something that simple?!
 

Mr. B

"Doctor Access"
Local time
Today, 04:02
Joined
May 20, 2009
Messages
1,932
Hey, Linq, another good catch. I did not realize that it was a 2007 database either.
 

Users who are viewing this thread

Top Bottom