Visualizzazione dei risultati da 1 a 5 su 5

Discussione: DBGrid e Access

  1. #1
    Utente di HTML.it
    Registrato dal
    Feb 2002
    Messaggi
    153

    DBGrid e Access

    Salve a tutti,
    è tanto che non programmo in Visual Basic, quindi mi sono creato una mini applicazione per ripassare un poco.

    Gli oggetti inseriti sono:
    Data -> collegato ad un db e ad una tabella tramite le proprietà.

    DbGrid -> collegato a data tramite le proprietà.

    ho una text in cui introduco un valore, come faccio a ripulire il Dbgrid e ricaricarlo con i campi uguali al valore immesso?

  2. #2
    non capisco la richiesta.... puoi fare un esempio?

  3. #3
    Utente di HTML.it
    Registrato dal
    Feb 2002
    Messaggi
    153
    ho risolto!!


    Ok, I have a DBGRID, I want to fill this grid with information from two differnt Databases(not differnt tables) how would i go about doing this? Both are access databases.




    This is using the DATA component not ADO, how i would love ADO but the rest of the program is in DATA, I am just modifying it so i cant change this



    Is this possible? Anyone have any ideas?



    Yes it is possible.
    Having two dataobjects each linked to it own source.
    Then have the dbgrids each linked to the relative dataobject.
    If the two databases are related then in the primary dbgrid rowcolchange event you would need to do a select query on the second dataobject to display only the related records in the second dbgrid.
    Hope it is clear enough.



    Is it possible to get some sort of example, i am kind a confused.



    Examples are said to help to much.
    I believe that even an example makes you learn, even of it is not much more than, debugging somebody else's code.
    Place two datagrids on a form, and two database objects. Ensure that each datagrid has a database object set as its datasource. Then using the following code you will access the databases in a relational fashion. Thus achieving relational database functionality with a one to many on two dbgrid's.




    '*************************

    Public database1, database2, table1, table2, linkfield, selectfield


    Private Sub Command1_Click()

    database1 = "data1.mdb"
    database2 = "data2.mdb"

    table1 = "students"
    table2 = "studentmarks"

    Data1.DatabaseName = database1
    Data2.DatabaseName = database2

    Data1.RecordSource = table1
    Data2.RecordSource = table2

    Data1.Refresh
    Data2.Refresh

    linkfield = "StudentID"

    DBGrid1.ReBind
    DBGrid2.ReBind

    DBGrid1.Refresh
    DBGrid2.Refresh


    End Sub

    Private Sub DBGrid3_Click()

    End Sub

    Private Sub DBGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)

    If DBGrid1.Bookmark <> "" Then

    selectfield = Str(DBGrid1.Columns(linkfield).CellText(DBGrid1.Bo okmark))
    Data2.RecordSource = "Select * FROM " & table2 & " where " & linkfield & " = " & selectfield
    Data2.Refresh
    DBGrid2.ReBind
    DBGrid2.Refresh

    End If

    End Sub

  4. #4
    Utente di HTML.it
    Registrato dal
    Feb 2002
    Messaggi
    153
    solo che ora ho un problema con le funzioni!!



    ho 4 variabili stringa dichiarate all'interno di un modulo(a1,a2,a3,a4) insieme ad una funzione:
    public sub carica(b1 as string,b2 as string,b3 as string,b4 as string)
    end sub

    quando la chiamo "call carica(a1,a2,a3,a4)" dal mio form mi da questo errore "istruzione non valida all'esterno del blocco type"



    la sintassi è giusta?

  5. #5
    Utente di HTML.it
    Registrato dal
    Feb 2002
    Messaggi
    153
    risolto tutto!
    thanks

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.