[AccessD] Forcing an event

Stuart McLachlan stuart at lexacorp.com.pg
Wed Nov 12 14:36:11 CST 2014


I'd go with the last paragraph. It's not gruesome, it's trivial  That's what OpenArgs is for. Just 
pass an appropriate value in the Docmd.OpenForm from wherever you invoke it and the form 
knows why it is opening. 

Don't enable/disable controls in an On_Click event.  Set them in a separate Sub, then you 
can invoke the code from the On_Open based on OpenArgs or from any other event on the 
form. 

-- 
Stuart

On 12 Nov 2014 at 15:12, Susan Harkins wrote:

> I have a command button on one form that opens a second form. On the
> second form, I use a click event to enable and disable other controls
> based on the value in the clicked event.
> 
> I'm also passing a value to the second form and using that to filter
> the form's Recordset -- so the control that determines the disabling
> and enabling has a selected value. I need to force that click to
> enable and disable the other controls.
> 
> All this happens for me automatically when opening the form for new
> records, because the user must select a value to trigger the event
> that disables/enables the other controls. When opening from the other
> form, however, the value is already set to the appropriate animal's
> record.
> 
> I tried the Call statement to force the click event, but it doesn't
> work. I think the problem is that the code calling is on the first
> form. When I explicitly name the form in the Call statement, I get an
> error --
> 
> Call Forms![Enter Disposition Details]!lstDispositionDetailsID_Click()
> 
> VBA just won't take that syntax. I looked it up and Call wants only
> the procedure name.
> 
> I suppose I could write some kind of evaluation in the form's open
> event that tries to determine how the form is being opened, but that
> sounds gruesome. I can train the user to just click the control of
> course, but that's error prone because users forget.
> 
> Any suggestions?
> 
> Susan H.
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 




More information about the AccessD mailing list