Coding Problem (Who is smart enough to help?)

T

Tony K

I'm note sure how to state this but, I have a Windows form that contains 2
tables. Details View on top and Datagrid on the bottom. The two tables are
related. One of the fields in the details view is a calculated field not
stored in the database. It needs to be calculated when any of 3 columns in
the datagrid are changed.

problem 1: What event for the datagrid is triggered when a cell is modified
AFTER it has loaded?
CellValueChanged or DataMemberChanged does not seem to work because one or
the other are triggered when the form is loaded.

problem 2: Any of the columns can contain null values. How do I write a
SQL statement to ignore null values. If there is at least one value in each
of the 3 columns, the statement below works great. Here is a glimse of my
SQL statement:

SELECT SUM(UnitsReceived) - SUM(UnitsSold) - SUM(UnitsShrinkage) AS
UnitsOnHand
FROM [Inventory Transactions]
WHERE (ProductID = ?)



The database is MSAccess. I downloaded it from Microsoft as a template for
inventory control and modified to my needs.


Thanks,
Tony
 
S

Stephany Young

Please note the change in subject. Such 'smart' comments are the easiest way
to have potential responders ingnore your post. 'nuff said on that subject.

Problem 1:

There are at least two approaches to this 'problem'.

1. Create a boolean variable with 'form' scope. Set
the variable in the constructor of the form, prior to
'InitialiseComponent'. Reset the variable as the last
statement in the form.Load event handler. In the
event handler for CellValueChanged test the variable.
If it is set then return immediately.

2. Do NOT 'wire' up the event handler for
CellValueChanged at design time. Use AddHandler to
'wire' it up after the data is 'loaded'.

My recommendation is approach 2.

Problem 2:

To ignore rows where ALL 3 columns are NULL then it is
a matter of:

select
sum(UnitsReceived)-sum(UnitsSold)-sum(UnitsShrinkage) as UnitsOnHand
from
[Inventory Transactions]
where
ProductID=? and
(UnitsReceived is not null or UnitsSold is not null or UnitsShrinkage
is not null)
 
T

Tony K

Thank you Stephany. I didn't mean anything by the 'smart' comment. I just
haven't had any luck here with anybody responding to my post about these
topics. See my post on 12-28 and 12-21 regarding the same subject.
Anyway, I will do those items you suggested.

Thanks,
Tony

Stephany Young said:
Please note the change in subject. Such 'smart' comments are the easiest
way to have potential responders ingnore your post. 'nuff said on that
subject.

Problem 1:

There are at least two approaches to this 'problem'.

1. Create a boolean variable with 'form' scope. Set
the variable in the constructor of the form, prior to
'InitialiseComponent'. Reset the variable as the last
statement in the form.Load event handler. In the
event handler for CellValueChanged test the variable.
If it is set then return immediately.

2. Do NOT 'wire' up the event handler for
CellValueChanged at design time. Use AddHandler to
'wire' it up after the data is 'loaded'.

My recommendation is approach 2.

Problem 2:

To ignore rows where ALL 3 columns are NULL then it is
a matter of:

select
sum(UnitsReceived)-sum(UnitsSold)-sum(UnitsShrinkage) as UnitsOnHand
from
[Inventory Transactions]
where
ProductID=? and
(UnitsReceived is not null or UnitsSold is not null or UnitsShrinkage
is not null)


Tony K said:
I'm note sure how to state this but, I have a Windows form that contains
2 tables. Details View on top and Datagrid on the bottom. The two
tables are related. One of the fields in the details view is a
calculated field not stored in the database. It needs to be calculated
when any of 3 columns in the datagrid are changed.

problem 1: What event for the datagrid is triggered when a cell is
modified AFTER it has loaded?
CellValueChanged or DataMemberChanged does not seem to work because one
or the other are triggered when the form is loaded.

problem 2: Any of the columns can contain null values. How do I write a
SQL statement to ignore null values. If there is at least one value in
each of the 3 columns, the statement below works great. Here is a glimse
of my SQL statement:

SELECT SUM(UnitsReceived) - SUM(UnitsSold) - SUM(UnitsShrinkage)
AS UnitsOnHand
FROM [Inventory Transactions]
WHERE (ProductID = ?)



The database is MSAccess. I downloaded it from Microsoft as a template
for inventory control and modified to my needs.


Thanks,
Tony
 
S

Stephany Young

I'm sure you didn't. Unfortunately, readers of your post cannot see you
'body language' and/or 'facial expression'. They can only read what is
there, and as you will be well aware some people read things into or take
offence at what may well have been meant as an innocuous statement. (You
only have to look at the myriad of threads where someone takes an
'innocuous' statement as a personal insult.

Having reviewed your earlier posts, all I can say is that if you had
described the issues as clearly as you did this time you may well have
received some positive responses to these posts.


Tony K said:
Thank you Stephany. I didn't mean anything by the 'smart' comment. I
just haven't had any luck here with anybody responding to my post about
these topics. See my post on 12-28 and 12-21 regarding the same subject.
Anyway, I will do those items you suggested.

Thanks,
Tony

Stephany Young said:
Please note the change in subject. Such 'smart' comments are the easiest
way to have potential responders ingnore your post. 'nuff said on that
subject.

Problem 1:

There are at least two approaches to this 'problem'.

1. Create a boolean variable with 'form' scope. Set
the variable in the constructor of the form, prior to
'InitialiseComponent'. Reset the variable as the last
statement in the form.Load event handler. In the
event handler for CellValueChanged test the variable.
If it is set then return immediately.

2. Do NOT 'wire' up the event handler for
CellValueChanged at design time. Use AddHandler to
'wire' it up after the data is 'loaded'.

My recommendation is approach 2.

Problem 2:

To ignore rows where ALL 3 columns are NULL then it is
a matter of:

select
sum(UnitsReceived)-sum(UnitsSold)-sum(UnitsShrinkage) as UnitsOnHand
from
[Inventory Transactions]
where
ProductID=? and
(UnitsReceived is not null or UnitsSold is not null or
UnitsShrinkage is not null)


Tony K said:
I'm note sure how to state this but, I have a Windows form that contains
2 tables. Details View on top and Datagrid on the bottom. The two
tables are related. One of the fields in the details view is a
calculated field not stored in the database. It needs to be calculated
when any of 3 columns in the datagrid are changed.

problem 1: What event for the datagrid is triggered when a cell is
modified AFTER it has loaded?
CellValueChanged or DataMemberChanged does not seem to work because one
or the other are triggered when the form is loaded.

problem 2: Any of the columns can contain null values. How do I write
a SQL statement to ignore null values. If there is at least one value
in each of the 3 columns, the statement below works great. Here is a
glimse of my SQL statement:

SELECT SUM(UnitsReceived) - SUM(UnitsSold) - SUM(UnitsShrinkage)
AS UnitsOnHand
FROM [Inventory Transactions]
WHERE (ProductID = ?)



The database is MSAccess. I downloaded it from Microsoft as a template
for inventory control and modified to my needs.


Thanks,
Tony
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top