Results 1 to 4 of 4

Thread: CheckBox(Resolved)

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    81

    Resolved CheckBox(Resolved)

    Hi,

    I create a form with 18 checkBox for the user to check the selected options.
    It will saved in a table in access. My coding is:

    Private Sub cmdSave_Click()
    Dim Index As Integer
    Dim status As Integer
    Dim chk As CheckBox

    Index = 0
    For Each chk In Check
    If Check(Index).Value = vbChecked Then
    status = 1
    End If
    Index = Index + 1
    Next

    If status = 1 Then
    If mode = "Add" Then
    rs_a.AddNew
    fill
    rs_a.Update
    MsgBox "One record is added"
    ElseIf mode = "Edit" Then
    fill
    rs_a.Update
    MsgBox "One record is updated"
    End If
    End If

    End Sub

    Private Sub fill()
    rs_a!ID = id.text
    rs_a!Newspaper.Value = Check(0)
    rs_a!Artile.Value = Check(1)
    rs_a!Banner.Value = Check(2)
    rs_a!CADDStudent.Value = Check(3)
    ..
    ..
    End Sub

    How can I retrieved the checked value from the table and display it back to the form by the ID??
    Please help !!
    Last edited by vivian2u; Mar 31st, 2005 at 05:26 AM.

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: CheckBox

    VB Code:
    1. With rsRecordset
    2. .activeconnection='your connection'
    3. .open "SELECT * FROM table WHERE ID = 'id value'"
    4. Check(0)=!Newspaper.Value
    5. Check(1)=!Artile.Value
    6. Check(2)=!Banner.Valuers
    7. Check(3)=!CADDStudent.Value
    8. ....
    9. ....
    10. End With
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: CheckBox

    You should rely on the default property of any control. You should check and set the checkboxes like this.
    VB Code:
    1. Check1.Value = vbUnchecked

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    81

    Re: CheckBox

    guys:

    Thanks. I have solved it with very simple code :


    Index = 0
    For i = 1 To 19
    If rs_a(i).Value = True Then
    Check(Index).Value = vbChecked
    End If
    Index = Index + 1
    Next


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