ABOUT form_on_current event

  • Thread starter Thread starter rudwan
  • Start date Start date
R

rudwan

i have form with subform , after open i want to make code
that once user dblclick any record on the subform to open
another form depending on one field
this code i make it at sub_form_on_current , it work
succesfully , but the problem is when sub_form open , it
automatically goto its first record , that means it will
run the code , which i dont like ,
who i can make the code to dont be run at first time ?
 
rudwan said:
i have form with subform , after open i want to make code
that once user dblclick any record on the subform to open
another form depending on one field
this code i make it at sub_form_on_current , it work
succesfully , but the problem is when sub_form open , it
automatically goto its first record , that means it will
run the code , which i dont like ,
who i can make the code to dont be run at first time ?

You say "dblclick any record", but using the Current event will make the
code run, not only when the subform first opens, but when the user
merely clicks on a record or even tabs to one. If you really want to
make the code run only when the user double-clicks, you can't use the
Current event. Instead, you need to use the DblClick event of several
different elements of the subform: the Form itself, the Detail section,
and each of the visible controls on the form. To avoid repeating code
in each of these events, what I would do is write a function in the
General section of the form's (that is, subform's) module. That
function would do the actual opening of the related form. Suppose that
function were along these lines:

Private Function fncOpenDetailForm()

DoCmd.OpenForm "frmDetail", _
WhereCondition:="ID=" & Me!ID

End Sub

Then I would use an expression in the OnDblClick event *property* of
each of the elements I mentioned, like this:

=fncOpenDetailForm()
 
yes , you are right , i mistake in my question , because ,
what i did before , i put this code :
private sub_form_current ()
msgbox EmployeeID
end sub

that just to know wether the form will identifi the
current id or not , it directly sent me message once open,
but i should not present my question as what i did ,
i agree with you that should be change the event to be on
dblclick
thanks
 
Back
Top