Code to open form based on value in text box

LisaP

Registered User.
Local time
Today, 20:56
Joined
Nov 13, 2000
Messages
27
I feel like such a durr today!

On my main form [Calls] i have the following controls:- text boxes - StartDate, StartTime, CloseDate, CloseTime, Fixtime. Combo box - Status.

I have created 2 subforms - calendars that work fine for StartDate (on got focus property opens form and transfers selection to relevant text box on main form). But what I want is IF the Status is "PENDING" there would be no need to have the second calendar open (as the call is not CLOSED).

I have tried this in a conditional macro - but the macro doesnt do anything. Have also tried VBA for this using an IF, Else statement, but this seems to open the subform regardless of the text box entry........

Grrrr

I am so sure this is so easy I'm almost embarassed to post question, but I am having a huge mental block over this one.
 
Actually, while what you are trying to do isn't all that difficult, there's a few small details that can get tricky, so don't feel bad!

There's a couple of things that could be going wrong. First let me ask where does the Status combo get it's values? Did you enter them in for the control or is it using values it's getting from a table?

If it's pulling them from a lookup table, there's a good chance that the combo box is bound to a different column then it's displaying. As a result, if you built your IF... THEN to look for the results from an unbound column, the IF...THEN wouldn't work b/c the control value would be that of the bound column.

The other thing is possibly the VBA was wrong. Assuming the combobox only has one column and the value you want to trigger the IF... THEN is "PENDING", here's an example of what your code would look like. Add it to the OnCurrent event:

----------------
If me.Status = "Pending" Then
me!FRM2ndCal.Form.visible = 0
End IF
----------------

This code says that if the value of Status is = to PENDING, then make the subform named FRM2ndCal invisible. Replace FRM2ndCal with the name of the form you want to be masked. It's important to have the .Form after the subform name it to indicate you are refering to a form's properties.

I hope this makes sense. Please let me know if not.

jamie

[This message has been edited by jstutz (edited 08-02-2001).]
 

Users who are viewing this thread

Back
Top Bottom