Macro RunCode Action Syntax for Referring to a Control on a Form ?

J

jhcoxx

Hi -

This question is a cross-post from microsoft.public.access.formscoding,
where it died out after several iterations of possible solutions - none
of which worked.

I'm trying to set up a function that will be used for several controls
on several forms - and will be called from an Access macro RunCode
action. This is a requirement due to ease of use and reuse issues.


The function is in a general VBA module and I need to pass it an object
reference to the form, an object reference to the control (usually a
listbox) and an integer.


The declaration of the function is


Public Function SetListBox(aForm As Variant, lbxBox As Variant, lItemNo
As Long)


and if I enter the following in the Function box of the RunCode action:



SetListBox([Form],[Forms]![frmAltOpStart]![lbxNonConIdx], 0)


the function sees the reference to the form and to the long integer,
but shows Null for the lbxBox variant. I've tried all the logical and
semi-logical syntax variations I can think of - with no success.

Any suggestions on the error (if not folly) of my ways - and any
suggestions on the separate problem of how to call this same function
from a subform on the form would be most appreciated!
From the previous post, the list box is set MultiSelect = None, and
using different declarations in the function specification (lbxBox As
Control, for example) have all failed to work.

Any insights from the wizards in this group?

James Cox
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top