Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

convert string data type to checkbox data type 1

Status
Not open for further replies.

5679

Programmer
Feb 14, 2003
32
AU
1. Dim varChb As CheckBox

'
'
'
2. Set varChb = rst!CheckboxName
3. varChb.Value = 1




rst is a recordset that contains a value retrieved from an access database.
CheckboxNAme is the field that stores names of checkboxes
The value is actually the name of a chechbox present on a VB form
I vant to set the value of the retrieved checkbox as 1 (line3)
I get a Type mismatch error on line 2!!
How to solve this??
 
Probably easiest way is to make all your checkboxes into an array and just store the index in the database.

Your first checkbox might be myChk(0), second one myChk(1) etc. Then just store the required index.

rst.Fields("chkIndex") = 1 (or whichever chkBox index value)

To get it back:
Dim intIndex as Integer
'Get your rst here
myChk(rst.Fields("chkIndex")) = 1

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Dim strChb As String
strChb= rst!CheckboxName & vbNullString
Me.Controls(strChb).Value = 1
 
Set varChb = rst!CheckboxName
You might try this
Set varChb = val(rst!CheckboxName)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top