473,394 Members | 1,951 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Reading SQL data into checkbox

Please someone help, i have been playing with the line of code for two days and still not getting anywhere.

I have a checkbox on my form called Chkrugby when this is clicked and saved to the sql table it is saved as 1, the data type on my sql table for this is set to bit. writing the data is fine and this works well the code is below.




Set rsRemote = New ADODB.Recordset

rsRemote.Open "cadets", sqlRemote, adOpenDynamic, adLockOptimistic

Me.Caption = "Setting values"
DoEvents
rsRemote.AddNew
rsRemote.Fields("chkrugby") = Me.chkrugby.Value
rsRemote.Update
rsRemote.Close
Set myRS = Nothing


the problem is when i am trying to load the same form that has been saved i am unable to populate the chkrugby box.

i have tryed the blow but hitting a wall please can anyone help?

Me.chkrugby = rsRemote.Fields("chkrugby")

i have also tryed

If rsRemote.Fields("chkrugby") = 1 Then Form1.chkrugby = 1

also

If rsRemote.Fields("chkrugby") = 1 Then Me.chkrugby = vbChecked
If rsRemote.Fields("chkrugby") = 0 Then Me.chkrugby.Value = vbUnchecked

and

If rsRemote.value("chkrugby") = 1 Then Form1.chkrugby = 1
Mar 22 '08 #1
1 1657
mafaisal
142 100+
Hello
Try This
Expand|Select|Wrap|Line Numbers
  1. If rsRemote.Fields("chkrugby") = 'True' Then Me.chkrugby.value = 1
  2.  If rsRemote.Fields("chkrugby") = 'False' Then Me.chkrugby.value = 0
  3.  
  4.  
I think this will work bcoz u use chkrugby as bit

Faisal

Please someone help, i have been playing with the line of code for two days and still not getting anywhere.

I have a checkbox on my form called Chkrugby when this is clicked and saved to the sql table it is saved as 1, the data type on my sql table for this is set to bit. writing the data is fine and this works well the code is below.




Set rsRemote = New ADODB.Recordset

rsRemote.Open "cadets", sqlRemote, adOpenDynamic, adLockOptimistic

Me.Caption = "Setting values"
DoEvents
rsRemote.AddNew
rsRemote.Fields("chkrugby") = Me.chkrugby.Value
rsRemote.Update
rsRemote.Close
Set myRS = Nothing


the problem is when i am trying to load the same form that has been saved i am unable to populate the chkrugby box.

i have tryed the blow but hitting a wall please can anyone help?

Me.chkrugby = rsRemote.Fields("chkrugby")

i have also tryed

If rsRemote.Fields("chkrugby") = 1 Then Form1.chkrugby = 1

also

If rsRemote.Fields("chkrugby") = 1 Then Me.chkrugby = vbChecked
If rsRemote.Fields("chkrugby") = 0 Then Me.chkrugby.Value = vbUnchecked

and

If rsRemote.value("chkrugby") = 1 Then Form1.chkrugby = 1
Mar 23 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Anna | last post by:
Hi all, I posted the same question this afternoon but my message isn't showing up, so I thought I'd give it another try.... in case you should see it later I apologize for posting the same...
4
by: Alex Sibilev | last post by:
Hello, I have a really weird problem I've been trying to solve it without any luck for the last couple of hours :( I'm writing a "conference board" application (quite similar to ASP.NET...
2
by: Nu2ASP.NET | last post by:
What I am trying to do is essentially 'flip' the bits, when the user clicks in the checkbox. For example, if the CheckBox appears checked, and the user un-checks it, I want the underlying data...
0
by: Serge | last post by:
Good Day Folks, I have a problem which used to work in ASP but does not work in ASP.NET. The form below with 3 checkboxes. <form method="POST" action="check2.aspx"> <input type="checkbox"...
4
by: sicapitan | last post by:
I have this code snippet: updateProps snippet: if (mycheckbox.checked == '1') ? $('mycheckbox').checked = true : $('mycheckbox').checked = false; content = $('mydiv').innerHTML;
1
by: mercercreek | last post by:
This one should be easy. Hope someone has a clue. Simple Scenario: Gridview with mulitple rows, each row with a checkbox. The user checks boxes of her choice. Clicks a button on the form (not in...
1
by: mfunkmann | last post by:
Hi, I recently got an error and I don't know how to fix it: Error 1 'System.Data.DataColumn' does not contain a definition for 'Windows' C:\c#\CsharpPRO\Form1.Designer.cs 304 77 CsharpPRO I...
4
by: ma | last post by:
Hello, I have a GrideView that has 4 col. 3 of them are bound to a dataset and the last one is not. The last one is check box. The check box is defined as follow: <asp:TemplateField...
4
by: lindabaldwin | last post by:
Hello all, I am fairly new to VBA and have had limited work with checkboxes before. I have turned an Excel worksheet into a form in which users can enter data and click checkboxes. I want to...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.