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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code stopped working 1

Status
Not open for further replies.

ptrifile

Technical User
Aug 10, 2004
457
US
I use simple code to make a text box visible when a specific option is chosen from a combo box. the code is

Code:
If REASON.Value = "Schedule_Issue" Then detailed_reason.Visible = True else detailed_reason.visible = False

It worked when i initially created the database but just stopped working for what seems like no reason. I have tried deleting the combo boxes off of the form and recreating and still no luck. Can anyone offer any suggestions?

Thank you in advance!

Paul
 
By "Stopped Working" what do you mean?, do you get an error message?

If you mean the control (detailed_reason) does not become visible then have you checked the (obvious) ie that REASON.Value is equal to "Schedule_Issue" by steppling through the code using a breakpoint?

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
 
by stopped working i meant that the control does not become visible, its just acting like there is no code written at all. If i create a blank database just to test and have 2 combo boxes and test the code it works fine. Nothing to my knowlege has changed to stop this from working as it worked when i first created it.

Thank you for the help
 
Have you checked that the event you are using for this code has [Event procedure] in the property sheet?
 
Thank you Remou, yes it has the [Event procedure] in the property sheet.

 
I have to be honest, I have tried but I really am not to familiar with it and dont know what im looking for. I only know some really basic code...can you walk me through it? Sorry for the ignorance.

Paul
 
As KenReay mentioned, one thing you are looking for is the value of Reason.

First, go to a code window and show the immediate window, if you have not already done so. You can do this by choosing it from the View menu or by pressing ctrl+G. Next, go to the start of the event procedure in which this code runs and press F9, this will toggle a breakpoint that should appear as a large dot in the margin.

You now need to use the form to run the event, that is, select the item that should cause detailed_reason to appear. This should 'jump' to the code window to the line with the breakpoint. Press F8 to step through the code. There are a variety of ways of looking at the values of variables, controls and fields and one of these is to use the immediate window. Typing:
?Me.Reason
for example, should show you the value of Reason, but only while you are stepping through the code.

Tell us what happens.

 
Remou, first off thank you very much for the hand holding!

ok so i performed the above steps....when running the event from the form the "if reason.value = "schedule_issue" then" is highlighted in yellow.

after typing ?me.reason in the "immediate" window underneath it "schedule_issue" appeared.

Thank is all that happened.
 
Well that certainly looks right. What happens when you press F8 again? Does it highlight the 'True' statement?
 
If i hit F8 it highlights "detailed_reason.visible = False
 
There is your problem. There must be some minor spelling difference or extra spaces, or you are using an event that occurs before the value is set. You can test this by typing in the immmediate window:

?Me.Reason="schedule_issue"
?Trim(Me.Reason)="schedule_issue"
 
Could you do it again but type

? reason.value

since given the code you posted it should have followed the opposite path

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
 
Remou, thank you so much!! I ended up copying right from the code into the value list and that did it! much appreciated.

Kenreay, thank you as well! I had been messing with the code trying to change the visible to false and true so i may not have switched it back when i posted....

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top