DBGrid Problem

DBGrid Problem

Post by Servicecare Technology Lt » Wed, 26 Apr 2000 04:00:00



I have a DBGrid control bound to an Access table.  If I add a record
to this grid, close the form and fill an unbound combo box on another
form with the contents of the same table, the newly added record is
not shown.

Do I have to force the grid to write to the table somehow?  It looks
as though it is storing it in memory as if I quit and restart the
program the data is there.  

I have tried .rebind and .refresh in the lostfocus event of dbgrid but
they don't make any difference.

Karl.

-------------------------------------------
Servicecare Technology Ltd

Computer/fax/audio visual repairs
Bespoke software design

551 Warwick Road
Tyseley
Birmingham
West Midlands
B11 2EX
United Kingdom

Tel:    +44 (0)121-707-6011
Fax:    +44 (0)121-693-9940
-------------------------------------------

 
 
 

DBGrid Problem

Post by Jim in Clevelan » Wed, 26 Apr 2000 04:00:00



> I have a DBGrid control bound to an Access table.  If I add a record
> to this grid, close the form and fill an unbound combo box on another
> form with the contents of the same table, the newly added record is
> not shown.

> Do I have to force the grid to write to the table somehow?  It looks
> as though it is storing it in memory as if I quit and restart the
> program the data is there.

> I have tried .rebind and .refresh in the lostfocus event of dbgrid but
> they don't make any difference.

  Hmmmm.  Is DBGrid bound to use a Data Control (i.e., DBGrid DataSource
is set to name of a Data Control)?  Is the DBGrid AllowAddNew property
set to True?  Cuz I just set up that scenario, added a record, then
populated an unbound Combo box and the new record shows up, no problem.
Could you please share the code you use to populate the Combo?  Maybe
problem lies there.
--
Jim in Cleveland
If you're writing to me, in my address
change "REAL_Address.see.below" to "worldnet.att.net"
 ((("What's so funny 'bout peace, love & understanding?" - Nick Lowe)))

 
 
 

DBGrid Problem

Post by Servicecare Technology Lt » Thu, 04 May 2000 04:00:00


Jim,

Yes, DBGrid DataSource is set to Data1 and AllowAddNew is set to True.
This is the code I'm using when populating the combo:

    If StockTable.RecordCount = 0 Then Exit Sub
    StockTable.MoveFirst
    Do Until StockTable.EOF
        If IsNull(StockTable![Stock Code]) Then
            StockLineCode$ = Space$(10)
        Else
            StockLineCode$ = Left$(StockTable![Stock Code], 10) &
Space$(10 - Len(Left$(StockTable![Stock Code], 10)))
        End If
        If IsNull(StockTable![Description]) Then
            StockLineDesc$ = Space$(25)
        Else
            StockLineDesc$ = Left$(StockTable![Description], 25) &
Space$(25 - Len(Left$(StockTable![Description], 25)))
        End If
        If IsNull(StockTable![Sale Price]) Then
            StockLinePrice$ = Space$(10)
        Else
            StockLinePrice$ = Format$(Left$(StockTable![Sale Price],
10), "000.00")
        End If
        StockListLine$ = StockLineCode$ & " | " & StockLineDesc$ & " |
" & StockLinePrice$
        cboFDStockList.AddItem StockListLine$
        StockTable.MoveNext
    Loop

I have also had other suggestions on how to cure this like doing a
stocktable.movefirst after adding a record, and also this code:

        If Not Adodc1.Recordset.BOF Then
        ElseIf Not Adodc1.Recordset.EOF Then
        Me.Adodc1.Recordset.Update
                Me.Adodc1.Recordset.Close
        End If

But neither of these made any difference.

I would try to use the grid unbound but I don't know which commands to
use to manipulate the grid.  

I appreciate you spending time helping me with this problem and look
forward to any further suggestions.

Regards,
Karl.

On Tue, 25 Apr 2000 21:38:14 GMT, Jim in Cleveland



>> I have a DBGrid control bound to an Access table.  If I add a record
>> to this grid, close the form and fill an unbound combo box on another
>> form with the contents of the same table, the newly added record is
>> not shown.

>> Do I have to force the grid to write to the table somehow?  It looks
>> as though it is storing it in memory as if I quit and restart the
>> program the data is there.

>> I have tried .rebind and .refresh in the lostfocus event of dbgrid but
>> they don't make any difference.

>  Hmmmm.  Is DBGrid bound to use a Data Control (i.e., DBGrid DataSource
>is set to name of a Data Control)?  Is the DBGrid AllowAddNew property
>set to True?  Cuz I just set up that scenario, added a record, then
>populated an unbound Combo box and the new record shows up, no problem.
>Could you please share the code you use to populate the Combo?  Maybe
>problem lies there.

-------------------------------------------
Servicecare Technology Ltd

Computer/fax/audio visual repairs
Bespoke software design

551 Warwick Road
Tyseley
Birmingham
West Midlands
B11 2EX
United Kingdom

Tel:    +44 (0)121-707-6011
Fax:    +44 (0)121-693-9940
-------------------------------------------

 
 
 

1. DBGrid problem - difficult problem

Hi all

The problem I have is the following:
  I have a grid, in which I enter values under particular columns.
  I want to be able to get a value entered in a particular row under a
certain column.
  Once I know the value, I want to be able to say that if the value is, e.g
= 1 then
  a cell in the same row under another particular column is read only.
  I don't want to make the whole column read only, just a particular cell
in a particular row and under a particular column.

e.g.

The following fields exist:
      Category field
      Description field
      Amount

Under the column Category and in a new row, I enter 'Parking' .
I want to be able to tell Delphi to get that value and say that if it is
'Parking' then the Description field in that row must not be filled in, i.e
the description field must be read only.
I then want to be able to go to the next new row and enter a description if
a description is required.
All in all, I just would like to set a particular cell to readonly and not
affect the fields at all and not affect any other entries into new rows.

I hope I have explained it clear enough. If anyone can help, please do!!

Thanks.

2. SQL - Span over multiple databases?

3. DBGrid - problem

4. Templates & ADO Parameters & C++

5. DBGrid Problem

6. Menu question

7. dbgrid problem

8. Master Database Restore Problems

9. DBGrid Problem!!!

10. dbGrid problems...

11. DBgrid problem

12. FRUSTRATING DBGrid problem...