cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Discovery is online this week, April 16 and 18. Join us for these exciting interactive sessions.
Choose Language Hide Translation Bar
PS_Ato
Level III

How to get content of text edit box into "variable"?

Hi,

I'am looking for an alternative to manual change of variable ("Inspection Lot") within the script itself.

 

former sript:

 

Names Default To Here( 1 );
Open Database(
"DBQ=X:...
WHERE User1 LIKE '%Inspection Lot%'", "HSS"
);

 

 

I tried this - s.below, but it does not work. The script is running, but the "variable" was not used. Probably something is wrong with the format. Looking for advice.

Thank you.

 

new script version:

 

Names Default To Here( 1 );
win = New Window( "Edit Box - Enter the Inspection Lot",
<<Modal,
<<Return Result,
Text Box( "HSS Test: Enter the Inspection Lot" ),
texteditbox = TextEdit Box( "Inspection Lot" ),
Text Box( "Pressing OK - display of HSS graphs will be done automatically." ),
Button Box( "OK" ),
Button Box( "Cancel" )
);

Open Database(
"DBQ=X:...
WHERE User1 LIKE '%{"texteditbox"}%'", "HSS"
);

 

1 ACCEPTED SOLUTION

Accepted Solutions
pmroz
Super User

Re: How to get content of text edit box into "variable"?

A few suggestions for posting in this forum:

 

  • Indent your code (right-click > Reformat script)
  • Paste the code into the forum using the <JSL> button.  That will retain syntax colors

 

On to your problem.  My code checks to see if a value was entered into the text box.  If there is a value there it creates a SQL string using the variable sql, and then calls Open Database.  Your code calls open database with the IF command inside it.  That won't work.

 

Try this code:

	If( tbox_value != "",
		sql = Eval Insert(
			"SELECT TRBallShearHSBTTSF.Sample, Test, .... 
FROM TRBallShearHSBTTSF INNER JOIN SSBallShearHSBTTSF
ON TRBallShearHSBTTSF.Sample = SSBallShearHSBTTSF.Sample
WHERE User1 LIKE '%^tbox_value^%'");
		);

		dsn_string = "DBQ=X:\- ...HS.mdb;DefaultDir=X:\- ...;Driver={Driver do Microsoft Access (*.mdb)};DriverId=..;FIL=MS Access;FILEDSN=X:\...dsn;MaxBufferSize=2048;MaxScanRows=8;PageTimeout=5;SafeTransactions=0;Threads=3;UID=admin;UserCommitSync=Yes;";

		Open Database(dsn_string, sql, "HSS-Dage 4000");
);

View solution in original post

4 REPLIES 4
pmroz
Super User

Re: How to get content of text edit box into "variable"?

You are calling the variable for your texteditbox "texteditbox", which is allowed but not good programming practice.  Here's how to use the value entered in the textedit box:


Names Default To Here( 1 );
tbox_value = "";
win = New Window( "Edit Box - Enter the Inspection Lot",
	<<Modal,
	<<Return Result,
	Text Box( "HSS Test: Enter the Inspection Lot" ),
	tbox = Text Edit Box( "Inspection Lot" ),
	Text Box( "Pressing OK - display of HSS graphs will be done automatically." ),
	hlistbox(
		Button Box( "OK",
			tbox_value = tbox << get text()),
		Button Box( "Cancel" )
	)
);

if (tbox_value != "",
	sql = evalinsert(
"SELECT foo, bar
   FROM utopia
WHERE User1 LIKE '%{^tbox_value^}%'");

	show(sql);
	Open Database("DBQ=X:...", sql, "HSS");	
);

If I enter ABC the log shows this:

sql = "SELECT foo, bar
   FROM utopia
WHERE User1 LIKE '%{ABC}%'";
PS_Ato
Level III

Re: How to get content of text edit box into "variable"?

Hi,

thank you very much for your fast reply. Unfortunately I don't know much about programming and I'am still struggling - see below:

 

Sorry - I did not understand, where to put the "IF-Command".

 

Open Database(
	"DBQ=X:\- ...HS.mdb;DefaultDir=X:\- ...;Driver={Driver do Microsoft Access (*.mdb)};DriverId=..;FIL=MS Access;FILEDSN=X:\...dsn;MaxBufferSize=2048;MaxScanRows=8;PageTimeout=5;SafeTransactions=0;Threads=3;UID=admin;UserCommitSync=Yes;",
	If( tbox_value != "",
		sql = Eval Insert(
			"SELECT TRBallShearHSBTTSF.Sample, Test, .... 
FROM TRBallShearHSBTTSF INNER JOIN SSBallShearHSBTTSF
ON TRBallShearHSBTTSF.Sample = SSBallShearHSBTTSF.Sample
WHERE User1 LIKE '%^tbox_value^%'",
			"HSS-Dage 4000"
		)
	)
);
pmroz
Super User

Re: How to get content of text edit box into "variable"?

A few suggestions for posting in this forum:

 

  • Indent your code (right-click > Reformat script)
  • Paste the code into the forum using the <JSL> button.  That will retain syntax colors

 

On to your problem.  My code checks to see if a value was entered into the text box.  If there is a value there it creates a SQL string using the variable sql, and then calls Open Database.  Your code calls open database with the IF command inside it.  That won't work.

 

Try this code:

	If( tbox_value != "",
		sql = Eval Insert(
			"SELECT TRBallShearHSBTTSF.Sample, Test, .... 
FROM TRBallShearHSBTTSF INNER JOIN SSBallShearHSBTTSF
ON TRBallShearHSBTTSF.Sample = SSBallShearHSBTTSF.Sample
WHERE User1 LIKE '%^tbox_value^%'");
		);

		dsn_string = "DBQ=X:\- ...HS.mdb;DefaultDir=X:\- ...;Driver={Driver do Microsoft Access (*.mdb)};DriverId=..;FIL=MS Access;FILEDSN=X:\...dsn;MaxBufferSize=2048;MaxScanRows=8;PageTimeout=5;SafeTransactions=0;Threads=3;UID=admin;UserCommitSync=Yes;";

		Open Database(dsn_string, sql, "HSS-Dage 4000");
);

PS_Ato
Level III

Re: How to get content of text edit box into "variable"?

Many, many thanks - my first dialog box works - I'am so happy!!! :-) :-)