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

Update Failures on my Datagrid/Subform 1

Status
Not open for further replies.

paulgenga

Programmer
Jan 8, 2004
61
KE
Hallo,

Please help, I am a new user of VB(6.0).
The datasource for my ("Child") datagrid is a view in SQL.
I have used ADO Data Control (Not coded).

I expect the datagrid to refresh as soon as the link field is inserted to have the other fields shown respectively from the related File.

I have used the command ADODC1.Refresh on the event of column_AfterChange it is not working.

Please help me understand.

pgenga
 
Very possibly because the event isn't firing when you expect it to. Try putting a message box (MsgBox "AfterChange" or something like it) in your event procedure, and see if the message shows.

HTH

Bob
 
Thank you very much for your response
This is how my class module looks like...
Code:
Dim WithEvents adoPrimaryRS As Recordset
Private DoingRequery As Boolean
Public Event MoveComplete()

Private Sub Class_Initialize()
  Dim db As Connection
  Set db = New Connection
  db.CursorLocation = adUseClient
  db.Open "PROVIDER=MSDataShape;Data PROVIDER=MSDASQL;dsn=THouseDSN;uid=;pwd=;"

  Dim PriRS As String, SecRS As String, test As String
  PriRS = "{select OfrID,Ofr_Dte,sale_yr,sale_id,ac_name from op_SaleOffer_h Order by OfrID}"
  SecRS = "{SELECT dbo.op_SaleOffer_d.LotID, dbo.op_SaleOffer_d.OfrID, dbo.op_SaleOffer_d.StockID, dbo.op_TallyIn_d.Year, dbo.op_TallyIn_d.StockNo," & _
                      "dbo.op_TallyIn_d.Invoice, dbo.op_TallyIn_d.Mark, dbo.op_TallyIn_d.Grade, dbo.op_TallyIn_d.Pkg, dbo.op_TallyIn_d.UnitKG, dbo.op_TallyIn_d.NetKG," & _
                      "dbo.op_TallyIn_d.TareKG, dbo.op_SaleOffer_d.Broker, dbo.op_SaleOffer_d.Pkg AS [Ofd Pkg], dbo.op_SaleOffer_d.NetWt AS [Ofd Kg]," & _
                      "dbo.op_SaleOffer_d.SmpWt " & _
         "FROM dbo.op_SaleOffer_d INNER JOIN dbo.op_TallyIn_d ON dbo.op_SaleOffer_d.StockID = dbo.op_TallyIn_d.ID}"
  
  Set adoPrimaryRS = New Recordset
  adoPrimaryRS.Open "SHAPE " & PriRS & " AS ParentCMD APPEND (" & SecRS & " AS ChildCMD RELATE OfrID TO OfrID) AS ChildCMD", db, adOpenStatic, adLockOptimistic

  DataMembers.Add "Primary"
  DataMembers.Add "Secondary"
End Sub
This is where I called the records on to my form for manipulation...
Code:
Private WithEvents PrimaryCLS As clsop_SaleOffer_h
Dim mbChangedByCode As Boolean
Dim mvBookMark As Variant
Dim mbEditFlag As Boolean
Dim mbAddNewFlag As Boolean
Dim mbDataChanged As Boolean

Private Sub Form_Load()
  Set PrimaryCLS = New clsop_SaleOffer_h

  Dim oText As TextBox
  'Bind the text boxes to the data provider
  For Each oText In Me.txtFields
    oText.DataMember = "Primary"
    Set oText.DataSource = PrimaryCLS
  Next
  grdDataGrid.DataMember = "Secondary"
  Set grdDataGrid.DataSource = PrimaryCLS
End Sub
I also tested the refresh here...
Code:
Private Sub grdDataGrid_AfterColUpdate(ByVal ColIndex As Integer)
'On Error Resume Next
Select Case ColIndex
    Case 2
     MsgBox "Got IT"
'        DataEnvironment1.rsop_SaleOffer_h.Open
        Set grdDataGrid.DataSource = PrimaryCLS
        DataEnvironment1.rsop_SaleOffer_h.Requery
End Select
End Sub

Errors are occuring whenever I try to update the datagrid.
Please help...
NB: The message pops up but the following codes miss out
 
I'm sorry, you'll need to be more specific, with regard to where "errors are occurring".

HTH

Bob
 
Merry Christmas & a Happy New Year...

I get this Error message when tring to update the column on the datagrid. Then I am unable to move to the next or any other record.
>> Error occured while trying to update record.

and when trying to add a record on the data grid..
>> Error occured while trying to add record.

Bob please advice.

This would then be followed by this msg.

>>Runtime Error 3704:
>>Operation is not allowed when object is closed

Ref: DataEnvironment1.rsop_SaleOffer_h.Requery

And when I try to open this as shown earlier:
DataEnvironment1.rsop_SaleOffer_h.Open

I get this error message
>>Runtime Error:
>>Operation is not allowed when object is open[/b]
Ref: DataEnvironment1.rsop_SaleOffer_h.open
 
Bob I found the poblem...
It had something to do with violation of my realationships on MS-SQL.

Thank you.

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top