Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

argument in Function error 1924 "name" is not an object

argument in Function error 1924 "name" is not an object

argument in Function error 1924 "name" is not an object

Good afternoon, thank you For the quick answers under the previous posts, there were difficulties.
In OptionGroup.InteractiveChange this code works

CODE -->

SortedData arNameTextField
FOR i = 1 TO ALEN(arNameTextField)
	cTextControlSource = 'ThisForm.text' + ALLTRIM(STR(i+3));
		 + '.ControlSource= ' +'"SortedData." + arNameTextField(i)'
	cLabelCaption = 'ThisForm.label' + ALLTRIM(STR(i));
		 + '.Caption = ' + '(arNameTextField(i))'

But when I want to transfer this code to a function, problems arise with SortedData
ConnectTxtBoxCursor(ThisForm, "SortedData", @arNameTextField)

CODE -->

FUNCTION ConnectTxtBoxCursor(myForm, nameCursor, arField)
	FOR i = 1 TO ALEN(arField)
		cTextControlSource = 'myForm.text' + ALLTRIM(STR(i+3));
			 + '.ControlSource= ' +'"nameCursor"+"." + arField(i)'
		cLabelCaption = 'myForm.label' + ALLTRIM(STR(i));
			 + '.Caption = ' + '(arField(i))'
error 1924 NameCursor is not an object
Didn't find anything on google

RE: argument in Function error 1924 "name" is not an object

Because you've got "nameCursor" in double quotes, it's taking that actual name as the name of the cursor. In other words, it's looking for a cursor named nameCursor, rather than a cursor whose name is passed in the parameter.

I think it should work if you take out the double quotes.


Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: argument in Function error 1924 "name" is not an object


Didn't find anything on google

I can't stress enough that looking for this sort of thing on Google is not the way to solve the problem. And it's certainly not the way to become a better programmer.

Instead, you should study your code closely to understand exactly what it is doing. If necessary, run it in the Debugger, and examine the actual value that is stored in cTextControlSource. If you did that, you would instantly see what's wrong.

By all means use Google to understand specific commands or functions. (But it's better to use the VFP Help for that.) But don't expect Google to solve your problems for you.


Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: argument in Function error 1924 "name" is not an object

I see Mike already addressed your core problem.

You make use of macrosubstitution as someone being proud to know it and liking it a lot.

What you do can be done much more directly, still using macro substitution, but just for the control name itself:


cTextControl = 'myForm.text' + ALLTRIM(STR(i+3))
&cTextcontrol..ControlSource = nameCursor+"."+arField(i) 
similar for the Labelcaption. What's true is, that no matter whether you build a string of a full line of code or just have a part like the control name as a macro, the compiler wil determine the full line and compile it. It also doesn't matter how many macros are used, it all ends up in onle line of code that is compiled. It's just often better to not make up the whole line, especially if building it up is more complicated than writing it down as is, without needing to think how to put it into a string, especially since string delimiters then become a problem.

Also, this only works provided Mike is right, nameCursor is a variable or parameter that has the name of the cursor/workarea, then you don't literally mean nameCursor, but it's a variable that contains the name and therefore you use it unquoted to get its value and not use its name.

Btw, it's not nice to have something like Text1,2,,3,4 and then even like in this situation, where I assume Text1,2 and 3 are for something else and the texboxes for the data start at Text4 for field1, etc.
This is not good style at all, I'll just let that stand alone, there are other ways to get this into a better way of addressing. But that's a longer lesson.

You can go one step further, when you make use of EVAL to get an object reference and then WITH


oTextControl = Eval('myForm.text' + ALLTRIM(STR(i+3)))
WITH oTextControl
  .ControlSource = nameCursor+"."+arField(i)
I won't make up an example to see if it even works shortened to


WITH Eval('myForm.text' + ALLTRIM(STR(i+3)))
  .ControlSource = nameCursor+"."+arField(i)

This way the compiler isn't needed to compile the line that has one or more macro substitutions.
Well, the far simplest way to get controls bound to fields is
1. open a table in the form dataaenvirnoment (at design time right click and pick data evironment)
2. Drag one field from the visual displayy of a table in the data environment to the form
3. done

This is not building up HTML at runtime, the form is ideally visually design and only needs to be run, not built up.

You have a textbox (usually) that already has controlsource set and a label in front of it with the field name as caption. And there are ways to make this even better.
The major point is actually not that it's easy to do as a drag&drop operation, you do smething in code that's better and easier one at design time. Once you have this all, you can rename the control, you can add controls that go
before it or after, and it all still works, while your code depends on no renumbering and is likely to fail one day someone has the idea of consolidating control names.


RE: argument in Function error 1924 "name" is not an object

Thanks for the help and advice, removing the quotes everything worked

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close