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

Where to put the table update

Status
Not open for further replies.

audiopro

Programmer
Apr 1, 2004
3,165
GB
I hope I can explain this scenario.

I have a customer mailing table from which I can add each customer to any one of 4 mailing lists via a logical checkbox in a grid.
Each section's selected customers can be added to the master send list and the selected customers from several sections can be added to the master send list (customer.shot).
There is an additional column of check boxes (customer.noshot) which, if checked, should not allow that particular record to be added to the send list. Once a checkbox in that row is checked, all the cells in that row of the grid are coloured red.
This is partially working, checking the 'noshot' checkbox turns the cells in the row red as required, using the 'gridcellcolour' method.
Code:
-InteractiveChange-
count for len(alltrim(shot))>0 to shotz
thisform.gridcellcolour()

this.Value = this.Value
thisform.Grid1.Refresh()

Code:
-refresh-
count for ((len(alltrim(shot))>0) and (customer.noshot != .t.)) to shotz

Now for the problem.
When a checkbox in the 'noshot' column is selected, the table needs to be updated and I thought that I could do it with
Code:
UPDATE CUSTOMER SET SHOT='' WHERE NOSHOT=.T.
in either the forms refresh method or the checkbox's refresh method but adding that line stops the checkbox from being checked.

What am I missing here?

and am I making any sense?




Keith
 
Why are you "using the 'gridcellcolour' method."?

If you want to change the color of the grid cell, it would be better to use the column's DynamicBackColor.
Something like:
Code:
IIF((!(NoShot,RGB(255,0,0),RGB(255,255,255))
You could also use the column's DynamicFontBold to further highlight the cell
Code:
IIF((NoShot,.T.,.F.)

In that manner the color would change automatically without the need for updating the Grid.

Good Luck,
JRB-Bldr


 
I have always struggled getting my head roung the convoluted logic which drives this language.
When I first started to change this app I tried
Code:
IIF((!(NoShot,RGB(128,255,128),RGB(255,128,128))
in the columns DynamicBackColor thinking that it would change the cell colour dynamically but nothing happened. So I am left wondering what illogical setting I need to play with to make the magic happen.

What do I use to fire the DynamicBackColor method?

Sorry if this sounds like a whinge but I spend more time getting this sort of thing to behave than I do on the actual nuts and bolts of the app.

Keith
 
Actually there are typos in the code samples I provided above. My apologies.

The DynamicBackColor code should be:
Code:
IIF(NoShot,RGB(255,0,0),RGB(255,255,255))

The DynamicFontBold code should be:
Code:
IIF(NoShot,.T.,.F.)

Good Luck,
JRB-Bldr


 
What do I use to fire the DynamicBackColor method?

It's a property, not a method. You do not call it. It is evaluated each time the grid is refreshed/painted.
 
Sorry if I am little confused with the terminology.
I have added
Code:
IIF(NoShot,RGB(255,128,128),RGB(255,255,255))
to the DynamicBackColor property and added
Code:
this.Value = this.Value
thisform.Grid1.Refresh()
to the InteractiveChange to make it refresh (as advised in a previous thread)

This brings me back to the same functionality as at the start of this thread where I needed to know where to put the table update.
When a checkbox in the 'noshot' column is selected, the table needs to be updated.
I thought that this would be the appropriate code
Code:
UPDATE CUSTOMER SET SHOT='' WHERE NOSHOT=.T.
but where would it go?

Keith
 
I have found that I can put the update command in the grid refresh but when I deselect a check box the displayed contents of the grid jump to a different part of the table.

Is there any way round that and why can I not put a variable count in the refresh method?

Keith
 
"I have found that I can put the update command in the grid refresh"

You should not need the Update/Refresh command at all to get the color to show.

As was explained above, the DynamicBackColor is a Property. And as such its resultant value/state should be exhibited immediately upon a change in the condition. This should not require any Grid1.Refresh

It differs from a Method which is code which is executed upon certain conditions (e.g. Clicking on an Object, etc.).

If things are not working immediately are you by chance updating a data table, but displaying in your Grid a View into the table or Query results from the table (which would need to be updated).

Good Luck,
JRB-Bldr
 
The colours in the grid do indeed update without using the refresh command but this was the state of affairs when this thread started.

If we concentrate on 2 of the columns.
SHOT - This is the master list of mailshot recipients
NOSHOT - If this is checked - this customer does not receive maishots.

If the NOSHOT checkbox is selected in a row where the SHOT column is marked 'yes', the SHOT column should be set to 'no'. This was the reason for doing a table update at this point and then refreshing the grid to reflect the new value of the SHOT column. The functionality works but the display usually jumps to another part of the table, not very pretty.

Keith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top