Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Editbox Controlsource

Status
Not open for further replies.

DEDMOD

Programmer
Feb 1, 2001
721
US
I have an editbox I'm using to display a memofield. I start out with the editbox.controlsource = myfield. Then later, depending on the option selected in an option group I may have editbox.controlsource = "". This works fine.

Later when I try resetting the controlsource to the original field I get an error stating that the controlsource has to be a variable reference (something like that; if this doesn't sound right, I'll check again). I have a number of textboxes which I'm doing the same thing to and don't get this error. Anybody know what I'm likely doing wrong? I've looked and looked and can't see a typing error; in fact I've retyped the whole thing just to be safe.
 
I've run into this in development occasionally. Can you paste the code so we can see exactly what it looks like?
 
This is in the interactive change event of my option group.
If you can't figure it out I'm doing a little project to memorize Bible verses.
Code:
DO CASE
	CASE this.value = 1
		*Code for Add to List
		thisform.cbscore.caption = "Save"
		thisform.tmessage.value = "Enter data then click 'Save'"
		thisform.tbook.controlsource = ""
		thisform.tchapter.controlsource = ""
		thisform.tverse.controlsource = ""
		thisform.tbook.value = ""
		thisform.tchapter.value = ""
		thisform.tverse.value = ""
		thisform.deditbox1.controlsource = ""
		thisform.deditbox1.value = ""
	CASE this.value = 2
		*Code for Display
		thisform.cbscore.caption = "Display"
		thisform.tmessage.value = ""
		thisform.tbook.controlsource = tverses.fbook_ref
		thisform.tchapter.controlsource = tverses.fchapter
		thisform.tverse.controlsource = tverses.fverse
		thisform.deditbox1.controlsource = tverses.ftext
	CASE this.value = 3
		*Code for Memorize
		thisform.cbscore.caption = "Next"
		thisform.tmessage.value = dispmessage
		IF thisform.oSelMode.value = 1
			thisform.deditbox1.controlsource = ""
			thisform.deditbox1.value = ""
		ELSE
			thisform.tbook.controlsource = ""
			thisform.tchapter.controlsource = ""
			thisform.tverse.controlsource = ""
			thisform.tbook.value = ""
			thisform.tchapter.value = ""
			thisform.tverse.value = ""
		ENDIF
	OTHERWISE
		*Should never happen
		MESSAGEBOX("Error, check code")
ENDCASE
thisform.refresh
The line that offends VFP is the one just before CASE this.value = 3. Note, there's still some other work to do on this code, but I figure I'd better get this bug fixed first. -- DED

 
Hi DED,

Put the controlsource for the editbox in quotes:

thisform.deditbox1.controlsource = 'tverses.ftext'

Jim
 
Ok, Jim, I'll try that. But why does it work for the other types of controls without the quotes? (Or when I'm dealing with MicroSoft is that a taboo subject? :p )

Dave Dardinger
 
Does it really work for the other controls? Doesn't for me (VFP 5.0).

Jim
 
Dave--

When you're working in the dev environment with the Properties window, you usually don't have to put the ControlSource in quotes...but when you do it programatically, you do have to. Does that help?
 
Actually I mispoke slightly. It wasn't that the textboxes were working, it's just that they didn't give an error message. This is what threw me. If I hadn't gotten the error message just on the editbox I'd have probably tried putting the source in quotes on my own; I know sometimes you have to quote and sometimes you don't, as chpicker points out. Anyway, it's working now, so thanks to all.

Dave Dardinger
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top