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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TextBox in a Customer Form

Status
Not open for further replies.

jlucio

Programmer
Mar 20, 2001
13
MX
How can I display a variable in a TextBox in a Customer Form?. For example, I want to display only part of a field, for example Left(customer.name,20), and of course, when I move the pointer, changes must be showed.
THank you
 
In the grid's RowColumnChange event, use something like:

ThisForm.TextBox1.Value = Left(customer.name,20)
Dave S.
 
Assuming your record movement always does a form refresh, then just add some code like this to the Refresh() event code:
Code:
ThisForm.text1.value = Left(customer.name,20)
Dodefault()
You'll probably want to either mark this text box as ReadOnly = .T. or put a RETURN .F. in the When() code - just so the user doesn't think they can change the value here.

Note: For something like this, I will often use a Label instead, so then the code would be:
Code:
ThisForm.label1.caption = Left(customer.name,20)
Dodefault()
This of course assumes the that label's AutoSize Property is set to .T.

Rick
 
jlucio

I'm not sure how Dave determined there was a grid involved. But you might want to use a function to substring to name to a variable and use that variable as a value of your textbox. And when you move the pointer, call on the function again. And set the controlsource of the textbox to the variable. Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
Thanks Dave and Rick.
Mike:
I agree with you, but, where must I put de Calling Function?. I have all the normal navigation buttons: Next, Previous, etc.
JLucio
 
jlucio

1. Modify your form and from the menu "Form->New method", call it chopname and put this code in it:
Code:
LOCAL cValue
SELECT myCursor
cValue = SUBSTR(myCursor.name,1,5)
thisform.text1.Value = cValue

Here is the rest of the form in code form:
Code:
PUBLIC oform1
oform1=NEWOBJECT("form1")
oform1.Show
RETURN
DEFINE CLASS form1 AS form
	DoCreate = .T.
	Caption = "Form1"
	Name = "Form1"
	ADD OBJECT text1 AS textbox WITH ;
		Height = 25, ;
		Left = 72, ;
		Top = 36, ;
		Width = 169, ;
		Name = "Text1"
	ADD OBJECT commandgroup1 AS commandgroup WITH ;
		AutoSize = .F., ;
		ButtonCount = 2, ;
		Value = 1, ;
		Height = 37, ;
		Left = 60, ;
		Top = 144, ;
		Width = 144, ;
		Name = "Commandgroup1", ;
		Command1.AutoSize = .F., ;
		Command1.Top = 5, ;
		Command1.Left = 5, ;
		Command1.Height = 27, ;
		Command1.Width = 66, ;
		Command1.Caption = "Next", ;
		Command1.Name = "Command1", ;
		Command2.AutoSize = .F., ;
		Command2.Top = 5, ;
		Command2.Left = 73, ;
		Command2.Height = 27, ;
		Command2.Width = 66, ;
		Command2.Caption = "Previous", ;
		Command2.Name = "Command2"
	PROCEDURE chopname
		LOCAL cValue
		SELECT myCursor
		cValue = SUBSTR(myCursor.name,1,5)
		thisform.text1.Value = cValue
	ENDPROC
	PROCEDURE Load
		CREATE CURSOR myCursor (Name c(20))
		INSERT INTO myCursor (name) VALUES ("Mike Gagnon")
		INSERT INTO myCursor (name) VALUES ("John Jones")
		INSERT INTO myCursor (name) VALUES ("Frank Girrard")
		INSERT INTO myCursor (name) VALUES ("Rick Bean")
		GO top
	ENDPROC
	PROCEDURE Init
		thisform.chopname()
	ENDPROC
	PROCEDURE commandgroup1.Command1.Click
		SELECT myCursor
		SKIP
		thisform.chopname()
	ENDPROC
	PROCEDURE commandgroup1.Command2.Click
		SELECT myCursor
		SKIP - 1
		thisform.chopname()
	ENDPROC
ENDDEFINE
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top