How to reference a subprocdure to a button

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I can't get a command button reference to a button. Every time I select the
[event procedure] on the button it creates a new sub procedure. I want to
reference this button to a procedure I already created. It keeps creating
new sub-procedures when I open the [event procedure] on the command button.
I gave it the name of the right procedure but when I click the button it
says member already exists. The reference is to the new procedure that
creates when you go to [event procedure]. Every time I open the properties
it is on an empty procedure below the one I want it to be on.
The other problem is when it creates a new subprocedure it says it is a
toggle button with a focus(). On got focus.

The sub procedure someone gave me doesn't have that it has a click event.
I can't figure out how to have a regular button. They all seem to be toggle
buttons. This is just for a report.

In case you want the subprocedure here it is:
Private Sub cmdOpenFilteredReport_Click()
'On Error GoTo Err_cmdOpenFilteredReport_Click
Dim stDocName As String
Dim strFilter As String
strFilter = "[ResolutionID] IN ('Resolved Some Issues', 'No Resolution',
'Full Resolution')"
stDocName = "rptMediatorEvaluation"
DoCmd.OpenReport stDocName, acPreview, , strFilter
End Sub

The original need is to filter a report on 3 categories of the REsolutionID.
tia, I hope you can clear this up.
 
Hi Janis,

Firstly, make sure you have a command button control on your form. Select
Event Procedure against the On Click event and click the elipse (3 dots).

This will create a blank click event for you. You can then reference
another procedure or function by calling it like this:

call SUBNAME(PARAMETERS)

or

dim i as integer
i = FUNCTIONNAME(PARAMETERS)

Assuming your function returns an integer.

Hope this helps.

Damian.
 
if the created procedure says "toggle button", then that's the control you
added to your form. open the form in Design view. if the Toolbox toolbar
isn't already open, then open it. "hover" your mouse pointer over each
button on the toolbar. the toggle button's tooltip says "Toggle Button".
keep going down (or across), reading the tooltip that pops up for each
toolbar button, until you get to the one that says "Command Button".

hth
 
Back
Top