Click event is not firing

Djblois

Registered User.
Local time
Today, 02:17
Joined
Jan 26, 2009
Messages
598
I created two new option buttons and named them. Then I added click event procedure for each. Then I am trying my form and the click event doesn't fire when I click on them. Anybody have any ideas?
 
Need a bit more information.

What is the code behind the OnClick events?
 
Code:
Private Sub testPastFuture()

    If Me.obFuture Then
        Form_subfrmSoloItaliaOrders.RecordSource = "qrySoloItaliaOrders"
    ElseIf Me.obPast Then
        Form_subfrmSoloItaliaOrders.RecordSource = "qrySoloItaliaOrdersPast"
    End If
    Form_subfrmSoloItaliaOrders.Requery

End Sub

Private Sub obFuture_Click()
    
    testPastFuture
    
End Sub

Private Sub obPast_Click()
    
    testPastFuture
    
End Sub

I put a break point in both of the Click events and the sub that they call but nothing happens when I click them.
 
If you copy the code from testPastFuture to directly behind the OnClick, does it work?
Failing that, if you put the same call to testPastFuture behind the form's OnOpen event, does it run when you open the form?
I'm just trying to narrow down whether the problem is the call or the code being called.
 
If I move the code directly behind the OnClick then it still doesn't fire. However, if I put the call in the forms OnOpen Event it runs
 
Okay, at least we know your code is correct. :)

I'm going to have a search to see if there is some limiting factor for setting recordources using buttons.:confused:
 
Put a message box statement in the event handler code - something like this:

MsgBox "The click event works!"

If that works, then we know it's just that your code does nothing.
 
Have you tried doing a .requery or a .refresh after changing the record source. If you haven't, then it is very likely you won't see the form change.
 
I put a break point in the code. And it doesn't break. That is how I know it is not firing.
 
Sounds really weird. When you right-click the button in design mode and select 'build event', does it definitely take you to the event handler you're expecting it to?
 
no it takes me to the getfocus of that same control. Then when I change the event to click at the top it jumps to my procedure.
 
oddly enough the code runs if I put it in the OnFocus event. Which is a work around - it should still give me the result that I want but now it is giving me an error on the first line of code:

Code:
Private Sub testPastFuture()

    If Me.obFuture.Value = 1 Then
        Form_subfrmSoloItaliaOrders.RecordSource = "qrySoloItaliaOrders"
    ElseIf Me.obPast Then
        Form_subfrmSoloItaliaOrders.RecordSource = "qrySoloItaliaOrdersPast"
    End If
    Form_subfrmSoloItaliaOrders.Requery

End Sub

It says "You entered an Expression that has no value." It says this after I clicked on it?? so it should have a value of true? shouldn't it?
 
I think the event links might have got messed up. Faced with this situation, I would:

-Copy and paste the code out to notepad or something (just for safekeeping)
-Delete the button control and create a new one
-Recreate the event code by opening the 'event' tab in the control's properties and clicking the 'On Click' event, then pasting in the code again.
 
you may have moved the button to/from another form, or a tab

in which case the click event setting doesn't copy across - so look at the properties, anmd make sure there IS a click event - if not reset it.
 
I have tried everything you both suggested already.

1) I have deleted them and recreated them.

2) I have gone through the build event right click option to make sure they are attached.

Neither of those things helped. Click event still does not work. I am considering rebuilding the form from scratch but that can get so annoying with all the controls in it.
 
Place your code into the Afterupdate() event.

David,
 
If you choose to place the code in the Afterupdate() event it should look like this:

Private Sub obFuture_AfterUpdate()
'Place your code here or testPastFuture

Private Sub obPast_AfterUpdate()
'Place your code here or testPastFuture


Another alternative is to create a module and place the code there, and use the OnClick or Afterupdate event to call the module.
 
i'm in the same boat. i'm working with MSAccess 2007.
all of a sudden click even stopped working. That started happening right after MS Access tried to install some component. It got hung during the installation , so I killed Access and from that point on, click event stopped working.
i tried creating a new form with a new button - still same thing.
interesting enough, i have Access2003 installed on the same Pc and the same project works on 2003.
unfortunately, i need to use 2007 because of some features that 2003 lacks.
i tied repairing MS Access, i even completely uninstalled it and then reinstalled it. SAME DEAL!!!
don't know what else to do.
 

Users who are viewing this thread

Back
Top Bottom