|
-
Mar 31st, 2005, 04:42 AM
#1
Thread Starter
Lively Member
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.
-
Mar 31st, 2005, 04:49 AM
#2
Re: CheckBox
VB Code:
With rsRecordset
.activeconnection='your connection'
.open "SELECT * FROM table WHERE ID = 'id value'"
Check(0)=!Newspaper.Value
Check(1)=!Artile.Value
Check(2)=!Banner.Valuers
Check(3)=!CADDStudent.Value
....
....
End With
-
Mar 31st, 2005, 04:59 AM
#3
Re: CheckBox
You should rely on the default property of any control. You should check and set the checkboxes like this.
VB Code:
Check1.Value = vbUnchecked
-
Mar 31st, 2005, 05:25 AM
#4
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|