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

Try to use a select Case Statement to update a record.

Status
Not open for further replies.

b31luv

Technical User
Feb 21, 2002
171
US
I have multiple lookup tables. Me.Text74 is based on a lookup table also. It's really a combo, started out as text and thought it would be better as a combo. I'll correct the name once it works. Anyway, this is how I thought this was suppose to work.

Whatever Me.Text74 equals then perform that duty. The values can only be what the different cases show (60, 75, 90), it is limited to the list. Do I need to add more to this or did I just put it together incorrectly?

By the way, I get no errors, and my Textboxes 46, 48 and 50 are not updating.

Before I put in the case the TextBox updated correctly. I wanted to try to use the Select Case in order to learn more about it. I know I can use the If Else Statement, so try to help me with the Case Statement, please.

Code:
Select Case Me.Text74
       
    Case 1 = 60
        'Me.Text74 = 60 'If Design Temp = 60 Degrees
        Me.Text50 = DLookup("Wire", [WireSize60], "[WireSize60].Ampacity >= Text42")
        Me.Text48 = DLookup("GND", "[WireSize60]", "[WireSize60].Ampacity >= Text42")
        Me.Text46 = DLookup("Conduit", "[WireSize60]", "[WireSize60].Ampacity >= Text42")
    Case 2 = 75
        'Me.Text74 = 75  'If 75 Degrees
        Me.Text50 = DLookup("Wire", [WireSize75], "[WireSize75].Ampacity >= Text42")
        Me.Text48 = DLookup("GND", "[WireSize75]", "[WireSize75].Ampacity >= Text42")
        Me.Text46 = DLookup("Conduit", "[WireSize75]", "[WireSize75].Ampacity >= Text42")
    Case 3 = 90
        'Me.Text74 = 90 'If 90 Degrees
        Me.Text50 = DLookup("Wire", [WireSize90], "[WireSize90].Ampacity >= Text42")
        Me.Text48 = DLookup("GND", "[WireSize90]", "[WireSize90].Ampacity >= Text42")
        Me.Text46 = DLookup("Conduit", "[WireSize90]", "[WireSize90].Ampacity >= Text42")
            
End Select
 
I think your select statement is wrong. From the help file:
Code:
Function Bonus(performance, salary)
	Select Case performance
		Case 1
			Bonus = salary * 0.1
		Case 2, 3
			Bonus = salary * 0.09
		Case 4 To 6
			Bonus = salary * 0.07
		Case Is > 8
			Bonus = 100
		Case Else
			Bonus = 0
	End Select
End Function

Just put "Case [expression]", don't do any comparisons. So for yours, do "Case 60"/"Case 75"/"Case 90".

Second, your DLookups:

Code:
Me.Text50 = DLookup("Wire", [WireSize75], "[WireSize75].Ampacity >= Text42")
If you're getting the value of what is stored in Text42, do this:

Code:
Me.Text50 = DLookup("Wire", [WireSize75], "[WireSize75].Ampacity >= " & Text42.Value)
 
Thanks for your assistance. I'll try to use what you suggested next week and let you know how it worked.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top