Default

rhernand

Registered User.
Local time
Today, 01:17
Joined
Mar 28, 2003
Messages
96
How can I Default a Text Box value by the input of another two Text Boxes. This Expression on the Text Box Default Value does not work.

=IIf([Text0]=0 Or ([Text8]="<" And [Text0]=1),"White",IIf(([Text0]>=1 And [Text0]<=49),"Blue",IIf(([Text0]>=50 And [Text0]<=499),"Orange",IIf([Text0]>=500,"Yellow","No Input, left blank")))) :confused:

Other Text Boxes follow, I want to see the Default Value as soon as I leave Text0 and Text8.
 
Why not use VBA to assign the value in the After Update event of Text8?
 
Vba

I am not familier with VBA. I did add an Event on the AfterUpdate and this did not work. I am enclosing an example default.mdb.
 

Attachments

To be honest, looking at that table, I have no idea what it's supposed to be. I recommend how to design a database before you even think about using forms.
 
I have no problem with the table. I just sent this example mdb so you could visualize what I am trying to do. In this mdb I have only three fields, Symbol, PPM and Color. Originally, the client inputs a Symbol, a PPM value and, I had a List Box for the Color, with the list: "White", "Blue", "Orange" and "Yellow". The client would choose a Color from the drop down list. Since the Color is dependent on the Symbol and PPM, I want to eliminate the client from having to use the Color drop down list. In fact I do not even need the Color field in the table. I can always use the Expression to get the Color in forms, reports, etc. If I can get it to work.

=IIf([ppm]=0 Or ([symbol]="<" And [ppm]=1),"White",IIf(([ppm]>=1 And [ppm]<=49),"Blue",IIf(([ppm]>=50 And [ppm]<=499),"Orange",IIf([ppm]>=500,"Yellow","No PPM"))))
 
Rhernand, I have written up your code so that it works correctly, notice the 2 after update events that were added and the additional Sub Routine to check the color that should be written in the color text box. I have attached a working database for you to use.

Private Sub PPM_AfterUpdate()
'Calls the Subroutine Checkcolor to determine what color to write
'to the color text box
CheckColor
End Sub

Private Sub Symbol_AfterUpdate()
'Calls the Subroutine Checkcolor to determine what color to write
'to the color text box
CheckColor
End Sub

Private Sub CheckColor()
If PPM <= 1 Or Symbol = "<" Then
Color = "White"
End If

If PPM > 1 And PPM <= 49 Then
Color = "Blue"
End If

If PPM >= 50 And PPM <= 499 Then
Color = "Orange"
End If

If PPM >= 500 Then
Color = "Yellow"
End If
End Sub
 

Attachments

Works Great, Thanks

This is exactly what I needed. :)
 

Users who are viewing this thread

Back
Top Bottom