Results 1 to 4 of 4

Thread: Saving default values of checkboxes

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2004
    Posts
    5

    Saving default values of checkboxes

    Can someone help me out.

    I want to use default values for some checkboxes. Is use the following example in order to accomplish this:
    Me.CheckBox20.Checked = True

    Though the form has a databinding with an Access database and when I use Updatedataset, the checked values of the textboxes aren't stored within the database.

    How can resolve this problem?

    Ries.

  2. #2
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    if I understand your question, all you have to do is set the property in the control's property page to checked = true at design time.

  3. #3
    Hyperactive Member
    Join Date
    Mar 2004
    Location
    Prato - Tuscany - Italy
    Posts
    461
    I have never used databinding. I used Access, but practically I did everything with VBA. Actually I do something like you need, but, always, using code. In my table I added some boolean fields, that are updated by my application code.It seems strange that binding were not possible on boolean fields, anyway you can always use a separate updating by code in an event routine. I think, anyway, the better choice is to wrap your application to DB only by code! Good job!
    Live long and prosper (Mr. Spock)

  4. #4

    Thread Starter
    New Member
    Join Date
    Mar 2004
    Posts
    5
    if I understand your question, all you have to do is set the property in the control's property page to checked = true at design time. Andy

    Andy,

    I've tried both methods. I've tried to do it with the property page and I tried it with me.checkbox.checked = true in code.

    I think though the problem isn't the checking. It's the saving....
    Cause I can see my form actually use the default values of the checkboxes.....

    Here's my entire code routine for adding a database entry within access where I try to add the default value for the checkboxes.

    Private Sub MenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem4.Click
    Dim i, projectnumber As Integer
    Dim rw As DataRow
    rw = objpodataset.Tables(0).NewRow
    projectnumber = InputBox("projectnumber:")
    rw.Item("Projectnumber") = projectnumber
    Try
    Me.BindingContext(objpodataset, "PO Base").EndCurrentEdit()
    objpodataset.Tables(0).Rows.Add(rw)
    i = OleDbDataAdapter1.Update(objpodataset)
    Catch eEndEdit As System.Exception
    System.Windows.Forms.MessageBox.Show(eEndEdit.Message)
    End Try
    Me.objpodataset_PositionChanged()
    Me.LoadDataSet()
    Me.BindingContext(objpodataset, "PO Base").Position = (Me.objpodataset.Tables("PO Base").Rows.Count - 1)
    Me.objpodataset_PositionChanged()
    Me.CheckBox5.Checked = True
    Me.CheckBox7.Checked = True
    Me.CheckBox11.Checked = True
    End Sub

    I even tried to add Me.UpdateDataset() at the end of the routine, though this didn't had any effect.

    Hoping someone can help me out here....

    Ries

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width