Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Grid and related tables
Message
De
12/12/1997 00:50:27
Biju Varghese
M.H Alshaya Co W.L.L
Kuwait, Kuwait
 
 
Information générale
Forum:
Visual Basic
Catégorie:
VBA
Divers
Thread ID:
00065111
Message ID:
00065469
Vues:
45
>>>Yes I am using a data control and I'm setting its RecordSource property
>>>with an SQL. The updatable property is TRUE. Is everybody doing this?
>>>Or is it just me who is stuck!??!
>>>
>>>Thanks for the reply.
>>
>>Well, the answer to your question there is that no, not everybody does this. I do not use data controls at all. Have you tried to see what happens if you don't use a data control? I realize that this is not something that you may want to do.
>>
>>I'm not sure why it won't let you update the data. Can you post some sample code?
>
>
>Sure! Thanks a lot...

Here is the code sample I am using:

I have a form with a DBGrid and 2 DataControls.

Data1 -for 'Order' table (Oracle table attached to access)
Data2 -for 'OrderDet' table (Oracle table attached to access)

All the Data controls are invisible and updatable.
Below is the code I use for the Order table's Reposition


Private Sub Data1_Reposition()

If Data1.Recordset.EOF _
Or Data1.Recordset.BOF Then Exit Sub

Data2.RecordSource = "select a.DocNo, a.ItemNo, b.ItemName, " _
& " a.Qty, a.Rate, a.Qty * a.Rate as ItemValue " _
& " from OrderDet a, Items b " _
& " where a.ItemNo = b.ItemNo " _
& " and a.DocNo = '" & Data1.Recordset![DocNo] & "'"
Data2.Refresh

I even tried this with a plain form with just a DBgrid and Data control
and still it does'nt work. BUT IF THE SQL IS AS FOLLOWS, IT UPDATES!

Data2.RecordSource = "select a.DocNo, a.ItemNo, a.Qty, a.Rate "_
& " from OrderDet a " _
& " where a.DocNo = '" & Data1.Recordset![DOCNO] & "'"

Thanks a lot for helping..

For your further reference, I am pasting the code from the .FRM file:

VERSION 5.00
Object = "{00028C01-0000-0000-0000-000000000046}#1.0#0"; "DBGRID32.OCX"
Begin VB.Form frmOrders
BorderStyle = 1 'Fixed Single
Caption = "Order Entry"
ClientHeight = 3600
ClientLeft = 45
ClientTop = 330
ClientWidth = 6030
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 3600
ScaleWidth = 6030
Begin VB.Data Data2
Caption = "Data2"
Connect = "Access"
DatabaseName = "C:\Biju\vb\Orders\Orders.mdb"
DefaultCursorType= 0 'DefaultCursor
DefaultType = 2 'UseODBC
Exclusive = 0 'False
Height = 345
Left = 120
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = ""
Top = 3240
Visible = 0 'False
Width = 1140
End
Begin VB.TextBox txtDocNo
DataField = "DOCNO"
DataSource = "Data1"
Height = 285
Left = 840
Locked = -1 'True
TabIndex = 0
Text = "Text1"
Top = 240
Width = 975
End
Begin VB.Data Data1
Caption = "Data1"
Connect = "Access"
DatabaseName = "C:\Biju\vb\Orders\Orders.mdb"
DefaultCursorType= 0 'DefaultCursor
DefaultType = 2 'UseODBC
Exclusive = 0 'False
Height = 420
Left = 1560
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = "Orders"
Top = 960
Visible = 0 'False
Width = 1215
End
Begin MSDBGrid.DBGrid DBGrid1
Bindings = "frmOrders.frx":0108
Height = 1095
Left = 120
OleObjectBlob = "frmOrders.frx":0118
TabIndex = 12
Top = 2025
Width = 5775
End
End
Attribute VB_Name = "frmOrders"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public pcValidCode As String

Private Sub Data1_Reposition()

If Data1.Recordset.EOF _
Or Data1.Recordset.BOF _
Or glEditMode Then Exit Sub

Data2.RecordSource = "select a.DocNo, a.ItemNo, b.ItemName, " _
& " a.Qty, a.Rate, a.Qty * a.Rate as ItemValue " _
& " from OrderDet a, Items b " _
& " where a.ItemNo = b.ItemNo " _
& " and a.DocNo = '" & Data1.Recordset![DOCNO] & "'"

Data2.Refresh
End Sub

Private Sub DBGrid1_OnAddNew()

DBGrid1.Columns("DocNo") = Data1.Recordset!DOCNO

End Sub
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform