Hi 'Access' community,
I love MS Access. It's a great tool. I'm self taught in it and use Access 2003.
I've been trying to put together a select case statement in a form unload event. I've tried different scenarios of using the Me keyword, puting control names in [] and I can't seem to escape a 'debug' error.
The VBA I have put together seems to do the task but not in a speedy manner.
Allow me to put the code here:-
Too many cases/statements for a switch function. I've searched far and wide and had a go at putting together a Select Case Statement in VBA. Allow me to give a bit of background. The txtTrunk_Name is the name of the control on the form named "F_Hyperion Codes" and this form populates a text record in the Table "Hyperion Codes".
The txtRoot_Name is the name of the control on the same form. Aim is to use the trunk element to determine the root element.
I hope I'm not too far away with my efforts.
Really value any help/guidance to make it work smarter.
Xie xie Ni ! = Thank You !
I'm also learning Chinese!
Pablos
I love MS Access. It's a great tool. I'm self taught in it and use Access 2003.
I've been trying to put together a select case statement in a form unload event. I've tried different scenarios of using the Me keyword, puting control names in [] and I can't seem to escape a 'debug' error.
The VBA I have put together seems to do the task but not in a speedy manner.
Allow me to put the code here:-
Code:
Private Sub Form_Unload(Cancel As Integer)
Select Case Me!txtTrunk_Element
Case "10060" To "19999"
Me.txtRoot_Name = "INCOME"
Case "20000" To "29999"
Me.txtRoot_Name = "BALANCE"
Case "10000" To "10059"
Me.txtRoot_Name = "IC_SALES"
Case "40000" To "44999"
Me.txtRoot_Name = "BUSUNIT"
Case "45000" To "45999"
Me.txtRoot_Name = "APINT"
Case "50000" To "59999"
Me.txtRoot_Name = "KPI"
Case "60000" To "62999"
Me.txtRoot_Name = "TAX"
Case "63000" To "64999"
Me.txtRoot_Name = "ADDINFO"
Case "65000" To "69999"
Me.txtRoot_Name = "STATNOTE"
Case "70010" To "79999"
Me.txtRoot_Name = "BUSACQ"
Case "80000" To "89999"
Me.txtRoot_Name = "ESTIMATE"
Case Else
Me.txtRoot_Name = "CHECK!!"
End Select
End Sub
Too many cases/statements for a switch function. I've searched far and wide and had a go at putting together a Select Case Statement in VBA. Allow me to give a bit of background. The txtTrunk_Name is the name of the control on the form named "F_Hyperion Codes" and this form populates a text record in the Table "Hyperion Codes".
The txtRoot_Name is the name of the control on the same form. Aim is to use the trunk element to determine the root element.
I hope I'm not too far away with my efforts.
Really value any help/guidance to make it work smarter.
Xie xie Ni ! = Thank You !
I'm also learning Chinese!
Pablos
Last edited by a moderator: