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

Passing Variables

Status
Not open for further replies.

Guest_imported

New member
Joined
Jan 1, 1970
Messages
0
Please help, I am tring to pass field names from a text box to a variable, and then replace a field on my output file with whatever the field entered in the text box is, but it is replaceing the output field with the field name.

ex. they enter F1 in text box txtName

lcName = alltrim(ThisForm.txtName.Value)

select input
Scan while !eof()
scatter memvar
select output
replace Output.Name with (lcName)
select input
Endscan


well, thats basically it, but that replaces Output.Name with "F1" instead of the contents of Input.F1.

Thanks in advance

-BIBON

-Mike
 
P.S.

I though about doing a textmerge to a .prg file and then calling that program, but that seems like the hard way to do it.....
 
If I am understanding correctly, try:

variable = ThisForm.txtName.name
REPLACE (variable) WITH ALLTRIM(ThisForm.txtName.Value)

ThisForm.txtName.Name must be the same name as the table field though.

Dave S.
 
try expanding the variable by using the amphresand in front of the variable name

replace Output.Name with (&lcName)

this will be the equivalent of this:

replace Output.Name with (F1)

hope this what you were asking and it helps you with your problem

longda
 
The condition in the SCAN ENDSCAN being WHILE !EOF() is redundand and can be left out !!
SCAN ENDSCAN automatically scan throught the records and stops with the last record. Leaving out the condition will speed things up.

You store the value of your textbox in a variable.

if your variable would be "TestValue"

Your replace statement would be:

REPLACE myField WITH "TestValue", so if your variable would be:

MyVariable = "TestValue"

YOur replace statement would be:

REPLACE myField WITH MyVariable

leaving out the brackets !!.

HTH,
Weedz (Wietze Veld)
My private project:Download the CrownBase source code !!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top