|
-
Aug 5th, 2000, 05:58 AM
#1
Thread Starter
New Member
Hi all,
I have a checkbox in my program which returns 0/-1 to my database. When I read the database I want to show on the program whether the checkbox button is clicked or not. Please show me the code how to do that!
-
Aug 5th, 2000, 10:24 AM
#2
Monday Morning Lunatic
I had a similar thing to do for school a while back, and I wrote these two functions:
Code:
Public Function SetOption(sOptionName As String, iValue As Integer) As Boolean
Dim rst As Recordset
Dim bFound As Boolean
Set rst = CurrentDb.OpenRecordset("SELECT * FROM Options WHERE Name = """ & sOptionName & """")
If rst.RecordCount > 0 Then
rst.MoveFirst
rst.Edit
rst.Fields("Value").Value = iValue
bFound = True
rst.Update
Else
bFound = False
End If
rst.Close
SetOption = bFound
End Function
Public Function GetOption(sOptionName As String) As Integer
Dim rst As Recordset
Set rst = CurrentDb.OpenRecordset("SELECT * FROM Options WHERE Name = """ & sOptionName & """")
If rst.RecordCount > 0 Then
rst.MoveFirst
GetOption = rst.Fields("Value").Value
Else
GetOption = 0
End If
rst.Close
End Function
This works inside Access, out of Access, replace CurrentDB with the handle to your database. This assumes an 'Options' table with PK/AutoNumber ID, char(100) Name, and Integer Value.
Code:
Private Sub UpdateCheck()
chkMyCheckBox.Value = GetOption("chkMyCheckBox")
End Sub
This assumes that you have it set up in the table. If you want me to send an example DB and program that would be easy.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
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
|