combo on change pop up form.

doran_doran

Registered User.
Local time
Yesterday, 21:55
Joined
Aug 15, 2002
Messages
349
Hi everyone,

I have a combo box in my form. I have script behind on change which loads another form prompting end user put a date.

I WORKS GREAT.

I dont want to pop the window unless there is a change. Currently, when user click on drop down to see their option the other form pops up. Anyhelp will be appreciated. I want form to pop up only if the value has changed.

Regards
Dianna

Code behind after update:
============================================
On Error GoTo Err_Current_Status_AfterUpdate

DoCmd.OpenForm "frmPlanStatusDate", , , "[GA_Record_ID_2]='" & [GA_Record_ID_2] & "'"
DoCmd.close acForm, "frmgroups"
Exit_Current_Status_AfterUpdate:
Exit Sub
Err_Current_Status_AfterUpdate:
MsgBox Err.Description
Resume Exit_Current_Status_AfterUpdate
=============================================

I tried it on after update and change and same things happen. I want to pop the window only if the value has change to something else. But user should be able to click on drop down arrow and see available choices. currently, the form pops up no matter what.

Thanks
 
Use the Onchange event.

Or alternatively

Set the focus on the combo see code below:

Code:
me.combo.setfocus
me.combo.dropdown

change combo to the name of the combo box

Hope this helps

Andy
 
On Error GoTo Err_Current_Status_AfterUpdate
If Me.Dirty Then
DoCmd.OpenForm "frmPlanStatusDate", , , "[GA_Record_ID_2]='" & [GA_Record_ID_2] & "'"
DoCmd.close acForm, "frmgroups"
End If
Exit_Current_Status_AfterUpdate:
Exit Sub
Err_Current_Status_AfterUpdate:
MsgBox Err.Description
Resume Exit_Current_Status_AfterUpdate
 
or how about this way?

Private Sub cmb_AfterUpdate()
Dim cmbBefore As String
Dim cmbAfter As String


cmbBefore = Nz(Me.cmb.OldValue, "Null")
DoCmd.RunCommand acCmdSaveRecord
cmbAfter = Nz(Me.cmb, "Null")

If cmbBefore <> cmbAfter Then
MsgBox "combobox value has changed so open the form"
Else
MsgBox "combobox value has NOT changed so DON'T open the form"
End If


Not as dirty as rich but then who is? :D
 
Last edited:
Thanks everyone. It worked

Thanks everyone to pitch in. dan-cat sugession seems to work better than others.

However, Thanks everyone to let me see things from different angels.

Regards
Dianna
 
Re: Thanks everyone. It worked

Jamils_gateway said:
Thanks everyone to pitch in. dan-cat sugession seems to work better than others.
Regards
Dianna

Yes, in your face :D
 

Users who are viewing this thread

Back
Top Bottom