473,408 Members | 1,749 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,408 software developers and data experts.

List Box And Adodb Combination

72
Hey guys i have a question am having trouble in displaying record in a list box, what i want to achieve is this... i have 2 check boxes, checkbox1 is name MEASLES and checkbox is name "CHICKEN POX". i have a database name MEDICALDB and has 4 tables named STUDENT NUMBER, NAME, CHIKEN POX AND MEASLE..

i have this example database record:

Student Number Name Chiken Pox Measles
200013253 Darrel NO NO
200013254 Gary YES NO
200013255 Norman NO YES
200013256 Larry YES YES

The scenarion i wanted to search for the names that have value of YES in the Chicken Pox Field and display the name in a listbox..

I'am having trouble on how to implement it in my program so far i have this codes:

Expand|Select|Wrap|Line Numbers
  1. Dim rsShowrec1 As New ADODB.Recordset
  2. Dim cnn As New ADODB.Connection
  3.  
  4. Set cnn = New ADODB.Connection
  5. cnn.ConnectionString = _
  6.  "Provider=Microsoft.Jet.OLEDB.4.0;" & _
  7.           "Data Source=" & App.Path & "\MedicalDB.mdb;"
  8. cnn.Open
  9.  
  10. If check1.value = 1 Then
  11. Label1.caption = "YES"
  12.  
  13. On Error Resume Next
  14. rsShowrec1.Source = "SELECT * FROM MecidalData where [CHICKEN POX] = ' " & Label1.caption & " '
  15. rsShowrec1.Open , cnn, adOpenStatic, adLockOptimistic
  16.  
  17. If rsShowrec1.EOF <> True Then
  18. List1.AddItem rsShowrec1.Fields("Name").Value
  19. rsShowrec1.MoveNext
  20. end if
  21. End Sub
  22.  
So far its not working... Any help will do... Thank you... i hope your getting wat i want to achieve... By d way am using ADODB for my database connection.
Oct 26 '07 #1
7 1751
debasisdas
8,127 Expert 4TB
try this
Expand|Select|Wrap|Line Numbers
  1. sqlstr= "SELECT * FROM MecidalData where [CHICKEN POX] = ' " & Label1.caption & " '
  2. rsShowrec1.Open sqlstr, cnn, adOpenStatic, adLockOptimistic
  3.  
  4. Do While rsShowrec1.EOF = False
  5. List1.AddItem rsShowrec1!name
  6. rsShowrec1.MoveNext
  7. Loop
  8.  
Oct 26 '07 #2
Killer42
8,435 Expert 8TB
My guess is, this is VB6 - right?

So what's wrong with your current code? "Not working" is pretty vague. Is it producing an error? If so, what error and at what line of code? If not, in what way does it not match what you expect?
Oct 26 '07 #3
darrel
72
Theres no error on runtime my problem is the name are not populated in the list box. i will try another sequence. ill keep you posted . Many thanx.
Oct 27 '07 #4
darrel
72
Hello, ive tried what debasisdas suggestion, no sad to say no luck, there no error on runtime, but it doesnt populate my database record in the listbox and it has infinite loop.

Any more suggestion am badly need to finish this task so that my system will be implemented... Thank you..
Oct 27 '07 #5
9815402440
180 100+
hi

the problam is in your query. if datatype of the [CHICKEN POX] is YesNo then
then your query must like this

SELECT * FROM MecidalData where [CHICKEN POX] = " & iif(Label1.caption = 'Yes',True,False)


regards
manpreet singh dhillon hoshiarpur
Oct 27 '07 #6
darrel
72
Thank you for all the advice and tips. I figured out how I can populate database records in my list box, I just used the long method procedure.

Now, I have a new question for you guys. Now that I'm able to populate database records in my lists, what I wanted to do now is to populate all the items in my lists to a datareport to produce a hard copy.

Can you give me sometimes, I'm nearly close in finishing my Medical and Dental Record System.

Thank you, it's good to belong here... hooray!
Oct 27 '07 #7
QVeen72
1,445 Expert 1GB
Hi,

In DataEnvironment, add a Connection object and set the parameters to the database and test the connection. Right click Conn and add a Command object. Change the SQL query as "Select * From MyTable".

Add a new DataReport to the project. Open the Command Object node. You will see all the fields. Drag them and drop them on the DataReport. Adjust the lines. And in VB6 to show the report:

DataReport1.Show

Regards
Veena
Oct 28 '07 #8

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

Similar topics

0
by: michael | last post by:
hi, i have to do a medium sized project using php. i'm new to php but i quite like the model-view-controller pattern. so i was thinking to use the following combination of frameworks: mojavi,...
0
by: Marcin Grzębski | last post by:
Hi All! I can't find any good equivalent of VB6 params from samples which should be used as a 2nd and 3rd parameter in method: Connection.OpenSchema(ADODB.SchemaEnum schema , object criteria...
8
by: Shi Mu | last post by:
How to run a function to make become ,1,4],]? Thanks!
26
by: Swroteb | last post by:
Hi there, I've got a reasonably sized list of objects that I'd like to pull out all combinations of five elements from. Right now I have a way to do this that's quite slow, but manageable. I...
0
by: Farmer | last post by:
Hi Folks, I have been trying for a whole day yesterday to find out how to do this and found nothing here (maybe I didn't look well enough I dont know). But here it is I found some code on msdn...
4
by: Fresh_Air_Rider | last post by:
Hi In the "good old" Classic ASP days, I used to stream records from a SQL Server database out to the user's browser in CSV format by using a combination of COALESCE and the ADODB.Stream object....
4
by: rn5a | last post by:
A Form has 2 select lists. The 1st one whose size is 5 (meaning 5 options are shown at any given time) allows multiple selection whereas the 2nd one allows only 1 option to be selected at a time. ...
30
ADezii
by: ADezii | last post by:
For this Tip, we will show you an extremely handy, multi-user, feature of Jet that allows you to manage Users more effectively. You can create a special, provider-specific Recordset in ADO that...
2
by: gismar | last post by:
hi!! i just started with access for my job in a small translation agency, i have a form where i can select a language combination, based on the combination i want to load a list of...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.