adding a Binding Yes/No field to a control fail please help 
Author Message
 adding a Binding Yes/No field to a control fail please help

Please can somebody help me
i try to bind a yes/no field to a control on a form (checkbox) but te value
don't react
the problem is i can't find te right information of the propery field

i want  to add controls to a form with all possibilities of a database (text
/ boolean / time / date / etc...., number , integer)
but i can't find the right information about using the property field of
Bindings collection.

thanx for help

Option Explicit

Private colBndNwind As New BindingCollection
Private rsNwind As New ADODB.Recordset
Private cn As New ADODB.Connection

'   Microsoft data binder collection
'   Microsoft axtivex data objects 2.5 library

Private Sub Form_Load()

   ' Set the Connection object parameters.
   With cn
      ' The following connection may or may not work on your computer.
      ' Alter it to find the Nwind.mdb file, which is included with
      ' Visual Basic.
      .Provider = "Microsoft.Jet.OLEDB.3.51"
      .Open "C:\Program Files\Microsoft Visual Studio\VB98\NWIND.MDB"
   End With

    ' Open the recordset object.
    rsNwind.Open "Select * From Products", cn

    ' Add Textbox
    Form1.Controls.Add "VB.TextBox", "txtproduct"
    Form1.Controls("txtproduct").Top = 100
    Form1.Controls("txtproduct").Width = 2000
    Form1.Controls("txtproduct").Height = 120
    Form1.Controls("txtproduct").Left = 700
    Form1.Controls("txtproduct").Visible = True

    'Add check box
    Form1.Controls.Add "VB.CheckBox", "chkbxDiscontinued"
    Form1.Controls("chkbxDiscontinued").Top = 500
    Form1.Controls("chkbxDiscontinued").Width = 2000
    Form1.Controls("chkbxDiscontinued").Height = 120
    Form1.Controls("chkbxDiscontinued").Left = 700
    Form1.Controls("chkbxDiscontinued").Visible = True

    Form1.Controls("chkbxDiscontinued").Visible = True

   ' Set the DataSource of the Bindings collection to the recordset.
   Set colBndNwind.DataSource = rsNwind

    'Add to the Bindings collection.
    With colBndNwind
        .Add Me.Controls("txtproduct"), "Text", "ProductName", , "product"
        .Add Me.Controls("chkbxDiscontinued"), "Value", "Discontinued", ,
    End With

   ' Print the properties of the objects in the collection.
   Dim bndObj As Binding
   Debug.Print "DataField", "PropertyName", "Key"
   For Each bndObj In colBndNwind
      Debug.Print bndObj.DataField, bndObj.PropertyName, bndObj.Key
End Sub

Private Sub Form_Click()
   ' Move to the next record by clicking the form.
End Sub

Mon, 16 Dec 2002 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. VB Bound Controls failing - help please

2. Help - Access yes/no fields upsized to SQL Server SQL_BIT fields

3. Bind Controls Yes or No?


5. VB & Bound Controls - help please

6. Yes/No Field and Check Box help

7. How to convert a Yes/No field to a numeric field

8. HELP, can't set a yes/no field in a access table

9. Bound texbox fails to Bind on some machines

10. Bound textbox fails to bind on some machines

11. Saving/Adding a record using data bound text fields


Powered by phpBB® Forum Software