Convert a string to an object.

  • Thread starter TonyAntique via AccessMonster.com
  • Start date
T

TonyAntique via AccessMonster.com

I am sure the solution as ever is simple but I can't crack it!

1 have two strings passed into a form eg. as:-

strForm = "frmTest"
strField = "txtDescription"

And I want to get them as say:-

Form_frmTest.txtDescription.value = ""

But

Form_strForm.strField.value = ""

obviously does not work.

Any ideas - Thanks Tony.
 
J

John W. Vinson

I am sure the solution as ever is simple but I can't crack it!

1 have two strings passed into a form eg. as:-

strForm = "frmTest"
strField = "txtDescription"

And I want to get them as say:-

Form_frmTest.txtDescription.value = ""

But

Form_strForm.strField.value = ""

obviously does not work.

Any ideas - Thanks Tony.

What do you mean by "passed into a form"? What form contains this code? Can
you RELIABLY count on frmTest (or whatever form's name is passed) being open
when the code executes?

The syntax would be

Forms(strForm).Controls(strField) = Null

or "" or whatever value you want to assign to that field; doing so will assume
that the form is in fact open and that the record that you want to affect is
selected. If the form is on a different record (because the user has done
something in the interim) you may destroy data that you don't intend.

What's the context? What exactly is this code intended to accomplish?
 
T

TonyAntique via AccessMonster.com

Thank you
The syntax was exactly what I wanted.
It is the simple things that are the worst to work out.
I am sure the solution as ever is simple but I can't crack it!
[quoted text clipped - 14 lines]
Any ideas - Thanks Tony.

What do you mean by "passed into a form"? What form contains this code? Can
you RELIABLY count on frmTest (or whatever form's name is passed) being open
when the code executes?

The syntax would be

Forms(strForm).Controls(strField) = Null

or "" or whatever value you want to assign to that field; doing so will assume
that the form is in fact open and that the record that you want to affect is
selected. If the form is on a different record (because the user has done
something in the interim) you may destroy data that you don't intend.

What's the context? What exactly is this code intended to accomplish?
 

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