LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Variable Undefined When Blank

I am having a problem when a field on the spreadsheet is blank. I
should be getting an error message passed back to the screen telling
the user that the field is blank. But instead I am getting an error
message that points to another field that has been filled in.

The users are able to select from a drop down list either a
pre-existing Excel spreadsheet or a blank spreadsheet where they can
enter the data. When they click the Store button, I am using
Javascript to validate the fields. If a particular field is not
entered or has invalid data, then an error message will appear on the
screen. In this case, I was testing for a blank field and did not get
the error message I was expecting. So I put in some Response.Write
statements to display what was in the field and in this case this is
where it showed up as undefined. If there is data in the field, then
the field displays correctly. The following is an example of the code:

do
{
indexRow+=1;
}
while (mExcelApp.ActiveSheet.Cells(indexRow, 1) != "RECORD");
indexRow+=2;

RecordCount = 0;

do
{

var xlSourceDoc = mExcelApp.ActiveSheet.Cells(indexRow, 2);
var xlRefNumber = mExcelApp.ActiveSheet.Cells(indexRow, 3);
var xlFYR = mExcelApp.ActiveSheet.Cells(indexRow, 4);
var xlClass = mExcelApp.ActiveSheet.Cells(indexRow, 5);
var xlNNNNN = mExcelApp.ActiveSheet.Cells(indexRow, 6);
var xlAAAA = mExcelApp.ActiveSheet.Cells(indexRow, 7);
var xlLLLL = mExcelApp.ActiveSheet.Cells(indexRow, 8);
var xlFFF = mExcelApp.ActiveSheet.Cells(indexRow, 9);
var xlLineDollarAmt = mExcelApp.ActiveSheet.Cells(indexRow, 10);
var xlLineUnits = mExcelApp.ActiveSheet.Cells(indexRow, 11);
var xlLineDesc = mExcelApp.ActiveSheet.Cells(indexRow, 12);

if ((xlSourceDoc == "") || (xlSourceDoc == null) || (xlSourceDoc
== "undefined"))
{
mError = 11;
mResults = showErrorMsg();
break;
}

if ((xlRefNumber == null) || (xlRefNumber == "undefined") ||
(xlRefNumber == ""))
{
mError = 12;
mResults = showErrorMsg();
break;
}

var xlFYRStr = String(xlFYR);
var xlFYRFirstChar = xlFYRStr.substr(0, 1);
var xlFYRLastTwoChar = xlFYRStr.substr(1, 2);

if (xlFYRFirstChar == "f" ||
xlFYRFirstChar == "p" ||
xlFYRFirstChar == "F" ||
xlFYRFirstChar == "P" ||
xlFYRFirstChar == "")
{
return true;
}
else
{
mError = 13;
mResults = showErrorMsg();
break;
}
<code trimmed

RecordCount+=1;
indexRow+=1;
}
while (RecordCount < xlRecCnt);

In showErrorMsg() is where I have my error messages defined and mError
= xx
returns a particular message. In this instance of my testing, I left
xlSourceDoc blank and should get error message #11. But instead I am
getting the error message #13, associated with the xlFYR field.

Being fairly new to both Excel and Javascript, I am at a lost as to
how to correct the problem. Does anyone have an idea what I need to
do? TIA for any help!

Mike
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Functions Undefined James O. Thompson Excel Worksheet Functions 2 January 20th 09 10:41 PM
Error: Undefined or non-rectangular name Conan Kelly Excel Worksheet Functions 0 August 7th 08 03:29 AM
how do I insert a variable amount of blank spaces in a formula? Lucy4484 Excel Worksheet Functions 1 January 14th 07 10:36 PM
Undefined function error CLamar Excel Discussion (Misc queries) 3 June 5th 06 07:07 PM
test for not blank, use value in cell and set as variable Robert Excel Discussion (Misc queries) 0 March 24th 05 11:25 PM


All times are GMT +1. The time now is 01:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"