How to construct an expression using Arrays?

G

Guest

MS Access, Windows XP
==================
hi,

I'm passing the name of the current form and name of the control as OpenArgs
to another form, and storing them in an Array. When closing the new form, I'd
like to update the value of the control on the first form using the form name
and the control name stored in the array.

I've tried this a few ways, and it is not updating the value of the control
on the first form. And, it makes some sense why it is not working.

I've tried: OnClose Event of the second form:
=========
strExpr = "[Forms]![" & varOpenArgsArray(0) & "]![" & varOpenArgsArray(1) &
"]"
strExpr = Me.Text0
{does nothing}
=========
[Forms]![varOpenArgsArray(0)]![varOpenArgsArray(1)] = Me.Text0
{run-time error}
=========

When I use this:
[Forms]![frmFirst]![LastName] = me.Text0
it works.

How can I correctly construct an expression in the second form using the
Array elements which are form name and control name?

Thanks for any help or pointers.

-Amit
 
G

Guest

Thanks, Douglas. That worked like a charm!!
Cheers,

-Amit


Douglas J. Steele said:
Forms(varOpenArgsArray(0)).Controls(varOpenArgsArray(1))

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Amit said:
MS Access, Windows XP
==================
hi,

I'm passing the name of the current form and name of the control as
OpenArgs
to another form, and storing them in an Array. When closing the new form,
I'd
like to update the value of the control on the first form using the form
name
and the control name stored in the array.

I've tried this a few ways, and it is not updating the value of the
control
on the first form. And, it makes some sense why it is not working.

I've tried: OnClose Event of the second form:
=========
strExpr = "[Forms]![" & varOpenArgsArray(0) & "]![" & varOpenArgsArray(1)
&
"]"
strExpr = Me.Text0
{does nothing}
=========
[Forms]![varOpenArgsArray(0)]![varOpenArgsArray(1)] = Me.Text0
{run-time error}
=========

When I use this:
[Forms]![frmFirst]![LastName] = me.Text0
it works.

How can I correctly construct an expression in the second form using the
Array elements which are form name and control name?

Thanks for any help or pointers.

-Amit
 

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