Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
DataGrid Usage
Message
Information générale
Forum:
Visual Basic
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00417985
Message ID:
00420272
Vues:
29
Hi Chad,

My dear, I'm still stuck, I faild to connect the DataGrid to my Recordset can u help me in this. To make it easy for you I am making somethisg like the invoice where I have a DataHeader table and DataDetail table, the header data will be in the main form textboxs and the details will be in a DataGrid (subform) and the DataGrid will be filled whenever user click a botton.

Can u advice me how to code this, pls.

one more thing which one is better to use FlixGrid or DataGrid ?

Many thanks


>It is possible but extremely annoying to get it to work without crashing your application here is some code that might get you started.
>
>
>'`'`'`'`'`'
>'frmBudget'
>'`'`'`'`'`'
>Option Explicit
>
>Private Sub DataGrid1_BeforeColUpdate(ByVal ColIndex As Integer, OldValue As Variant, Cancel As Integer)
>   If DataGrid1.Columns(ColIndex).Value = "" Then
>      MsgBox DataGrid1.Columns(ColIndex).Caption + " must contain a value"
>      Cancel = True
>   Else
>      If (ColIndex = 1 Or ColIndex = 2) And Not IsDate(DataGrid1.Columns(ColIndex).Value) Then
>         MsgBox DataGrid1.Columns(ColIndex).Caption + " must contain a valid date"
>         Cancel = True
>      ElseIf (ColIndex = 3) And Not IsNumeric(DataGrid1.Columns(ColIndex).Value) Then
>         MsgBox DataGrid1.Columns(ColIndex).Caption + " must contain a numeric value"
>         Cancel = True
>      ElseIf (ColIndex = 3) And DataGrid1.Columns(ColIndex).Value <= 0 Then
>         'Do not save the record if no value was entered for the amount
>         Cancel = True
>      End If
>   End If
>End Sub
>
>Private Sub DataGrid1_BeforeUpdate(Cancel As Integer)
>   If DataGrid1.AddNewMode = dbgAddNewPending Then
>      If DataGrid1.Columns(1) = "" Or _
>         DataGrid1.Columns(2) = "" Or _
>         DataGrid1.Columns(3) = "" Then
>            MsgBox "All values must be entered" + vbCr + "Press [ESC] to cancel Addition of record"
>            Cancel = True
>      End If
>      If Not IsNull(DataGrid1.Columns(3)) Then
>         If IsNumeric(DataGrid1.Columns(3)) Then
>            If DataGrid1.Columns(3) <= 0 Then
>               Cancel = True
>            End If
>         End If
>      End If
>   End If
>End Sub
>
>Private Sub DataGrid1_Error(ByVal DataError As Integer, Response As Integer)
>   If DataError = 7011 Then
>      Debug.Print "DataGrid1_Error -> " + Str(DataError) + ": Not an error just suppress action cancelled msgbox"
>      Response = 0
>      DataGrid1.SetFocus
>   Else
>      Debug.Print "DataGrid1_Error -> " + Str(DataError) + ": " + DataGrid1.ErrorText
>      Response = 1
>   End If
>End Sub
>
>Private Sub DataGrid1_OnAddNew()
>   DataGrid1.Columns(1).Value = FormatDateTime(Str(Year(Date)) + "/3/31", vbShortDate)
>   DataGrid1.Columns(2).Value = FormatDateTime(Str(Year(Date) + 1) + "/3/31", vbShortDate)
>End Sub
>
<><><><><><><><><><><><><><><><><><><><>
<><> REMEMBER,,,,KNOWLEDGE IS POWER <><>
<><><><><><><><><><><><><><><><><><><><>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform