Changes from a combo box

astarbyfar

Registered User.
Local time
Today, 15:36
Joined
Apr 27, 2003
Messages
93
I owe this forum my life! I have a combo box with no default value i.e. there is no value in the combo box when the form is loaded. When the combo box is updated from one certain value to another I want to make the neccessary changes. However if the box is changed from another value to a different one different changes are made.
Hopefully the following pseudo code will help

If combobox.value changes from 1 to 2
make changes1
ElseIf combobox.value changes from 1 to 3
make changes2
Else
make changes3

I understand this is not how it will be done but hopefully you will understand what I want. I think I may have to create a seperate function which will be called in the beforeupdate() method but Im not sure. Cheers
 
You need to user the AfterUpdate event of your combo box. The values [1,2,3] should be stored in the combox box and do what you want if the user has selected either value.
 
If the combobox is bound, you can use the oldvalue property to determine the original value. However, I would store the old value somewhere else like the Status Bar Text field, or use a global variable, or store it in a temporary table.


Code:
Public lngValueBeforeUpdate As Long

Private Sub TextBox_AfterUpdate()
    Select Case Nz(lngValueBeforeUpdate,0)
        Case 1:
            Select Case Me.TextBox.Value
                Case 2: 'Make Changes 1
                Case 3: 'Make Changes 2
            End Select
        Case Else:
            'Make Changes 3
    End Select

    lngValueBeforeUpdate = Me.TextBox.Value
End Sub
 
Im back!

Apoligies in the long delay for this reply but Ive been on holiday. Modest is there anyway you could explain what this code does as Im rather confused!
 

Users who are viewing this thread

Back
Top Bottom