[Ace] Save check boxes into MS Access' database ! Yes ! It's true !
Converts VB checkbox control values(checked/unchecked) into MS ACCESS value (0,-1) and vice versa. I came across this while I was doing my project. Seems like MS ACCESS doesn't support checkbox values yet. I couldn't find anything like it here in planet source code therefore I wrote this. I played around with MS A's boolean controls, and found out it returns values 0,-1.(not 0,1? )There for, I scribbled this up. Need to finish my project quick, hehe.Btw, if you guys have a better solution, or if there IS a solution, pls contact me, :P If you're using this code, pls credit me for my work, and vote for me !
Original Author: renyi[ace]
Inputs
see remarks
Assumptions
I'm assuming that u have a chkkeydrop, a .mdb file with a table(rooms) and a field(keydrop as yes/no).
Returns
see remarks
Side Effects
none that i know off
API Declarations
'Declare this either in general form or in a module
Public keydrop as integer
'Yes, I'm making a Hotel Man Sys, :P
Code
'Wonder why MS Access doesn't support this ?
'Manually converting access -1,0 to checkbox true/false value
'This procedure can be declare eithr in main form or a module
'When viewing data, MS ACcess value (0,-1) are changed into
'checkbox controls' (true/false) to be displayed.
Sub keydrop_check(keydrop)
Dim Room_found As Boolean
Room_found = False
With datrooms.Recordset
.MoveFirst
Do While Room_found = False And Not .EOF
If .Fields("Room No") = DatCheckin.Recordset.Fields("Room") Then
keydrop = .Fields("keydrop")
Room_found = True
Else:
.MoveNext
End If
Loop
End With
If keydrop = 0 Then
chkKeydrop = Unchecked
Else: chkKeydrop = Checked
End If
End Sub
'This is the click event for the checkbox
'
'Converts check/uncheck value into 0/-1
' and stores it back into MS Access DB
Private Sub chkKeydrop_Click()
datrooms.Recordset.Edit
If chkKeydrop = Checked Then
keydrop = -1
datrooms.Recordset.Edit
datrooms.Recordset.Fields("Keydrop").Value = "-1"
datrooms.Recordset.Update
Else:
keydrop = 0
datrooms.Recordset.Edit
datrooms.Recordset.Fields("Keydrop").Value = "0"
datrooms.Recordset.Update
End If
End Sub
Loading Comments ...
Comments
No comments have been added for this post.
You must be logged in to make a comment.