Help with Public Function/Sub

  • Thread starter Shane via AccessMonster.com
  • Start date
S

Shane via AccessMonster.com

Good Morning all. I am trying to wrap my mind around trying to change this:
rs!ComponentID = Forms![frmEvalTemplate]![cboChair] into being more dynamic
rather than static but keep running into walls. This is the only part of my
function that I am creating that I can't get to come out right. The 'rs!
ComponentID = Forms![frmEvalTemplate]!' part would always be static or the
same, but the '[cboChair]' part is what I would like to be dynamic. I am
going to have several cboBoxes on frmEvalTemplate and I would like to create
something that would concatenate the static part of the string to the dynamic
part of the string. I have attempted to use Screen.ActiveControl.Name and
can successfully get the cboBox name that I'm presently using but have been
unsuccessful combining that with the static part of the string. I could use
some help if someone is willing to lend a hand. I have posted this same
question on a different forum with no takers.

If I am going about what I'm trying to accomplish, then I am wide open to
different suggestions on how to do this.

TIA,
Shane
 
J

J_Goddard via AccessMonster.com

Hi -

Try using this:

Dim strControlName as string
strControlName = Screen.ActiveControl.Name
rs!ComponentID = Forms![frmEvalTemplate](strControlName)

John

Good Morning all. I am trying to wrap my mind around trying to change this:
rs!ComponentID = Forms![frmEvalTemplate]![cboChair] into being more dynamic
rather than static but keep running into walls. This is the only part of my
function that I am creating that I can't get to come out right. The 'rs!
ComponentID = Forms![frmEvalTemplate]!' part would always be static or the
same, but the '[cboChair]' part is what I would like to be dynamic. I am
going to have several cboBoxes on frmEvalTemplate and I would like to create
something that would concatenate the static part of the string to the dynamic
part of the string. I have attempted to use Screen.ActiveControl.Name and
can successfully get the cboBox name that I'm presently using but have been
unsuccessful combining that with the static part of the string. I could use
some help if someone is willing to lend a hand. I have posted this same
question on a different forum with no takers.

If I am going about what I'm trying to accomplish, then I am wide open to
different suggestions on how to do this.

TIA,
Shane
 
S

shanesullaway via AccessMonster.com

Mr. Goddard, you are a God-sent. I have tried so many different combinations
trying to get that to work and with one quick post you have me up and running.
Thanks a ton and I hope you have a great weekend.

J_Goddard said:
Hi -

Try using this:

Dim strControlName as string
strControlName = Screen.ActiveControl.Name
rs!ComponentID = Forms![frmEvalTemplate](strControlName)

John
Good Morning all. I am trying to wrap my mind around trying to change this:
rs!ComponentID = Forms![frmEvalTemplate]![cboChair] into being more dynamic
[quoted text clipped - 15 lines]
TIA,
Shane
 

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