473,402 Members | 2,072 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,402 software developers and data experts.

Using a list box

52
OK.
Im using Access and VB. I have data on two tables in access that I want to show on vb. 1 text box will show 1 data from 1table and same with the other table. i've opened both tables on vb using the recordset and the if not...EOF Then...MoveNext on the form load.
i'v put the code behind the listbox to show the data form the seperate tables in the textboxes but it still won't work. Could anyone please tell me what in missing. Please give all the solutions you have.

THANK YOU 4 ALL ANSWERS
Jul 3 '07 #1
7 1376
debasisdas
8,127 Expert 4TB
OK.
i'v put the code behind the listbox to show the data form the seperate tables in the textboxes but it still won't work. Could anyone please tell me what in missing. Please give all the solutions you have.

THANK YOU 4 ALL ANSWERS
I have all the solutions for you ,but can you kindly clarify this i'v put the code behind the listbox to show the data form the seperate tables in the textboxes

if u can post it clearly then it will be easier to understand and solve your problem.
Jul 3 '07 #2
Killer42
8,435 Expert 8TB
Ignore me - just registering an interest in this thread.
Jul 4 '07 #3
THEAF
52
OK. What I meant was...
I'm doing a school project. I'm making a system software for an internet cafe. For this I'm using Visual basic and Microsoft Access. I'm using this code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.  
  3.     Set dbMyDb = OpenDatabase("C:\Documents and Settings\Shahidul\My Documents\Computing Project\Database.mdb")
  4.     Set rsDvd = dbMyDb.OpenRecordset("DVD", dbOpenDynaset)
  5.  
  6. If Not rsDvd.EOF Then rsDvd.MoveFirst
  7. Do While Not rsDvd.EOF
  8.     lstdvd.AddItem rsDvd!DVD_no
  9.     lstdvd.List(lstdvd.NewIndex) = rsDvd!Name
  10.     rsDvd.MoveNext
  11. Loop
  12.  
  13.     Set rsMember = dbMyDb.OpenRecordset("Member", dbOpenDynaset)
  14.  
  15. If Not rsMember.EOF Then rsMember.MoveFirst
  16.  
  17. Do Until rsMember.EOF
  18.     rsMember.MoveNext
  19. Loop
  20.  
  21.  
  22. End Sub
  23.  
  24. Private Sub lstdvd_Click()
  25.  
  26. Set rsDvd = dbMyDb.OpenRecordset("DVD", dbOpenDynaset)
  27.  
  28.     txtdvdno.Text = rsDvd!DVD_no
  29.     txtname.Text = rsDvd!Name
  30.     txtTakendate.Text = rsDvd!Date_taken
  31.     txtReturndate.Text = rsDvd!Date_return
  32.     txtrent.Text = rsDvd!Renting_cost
  33.     txtbuy.Text = rsDvd!Buying_cost
  34.     txtmemberid.Text = rsMember!Member_id
  35.     txtFname.Text = rsMember!First_name
  36.     txtLname.Text = rsMember!Last_name
  37. End Sub
So when I click on the list box selecting one data should be taken from the DVD table and show in the specified box and data from the Member table should do the same in their textboxes. But I get an error NO CURRENT RECORD or some other error after I've tried to fix it. Have you got any solutions for this please?
Jul 5 '07 #4
Killer42
8,435 Expert 8TB
Can you tell us exactly where in the code the error occurs?
Jul 6 '07 #5
Killer42
8,435 Expert 8TB
Another question. At lines 17 to 19, why are you reading all of the member records, if you're not going to do anything with them?
Jul 6 '07 #6
Killer42
8,435 Expert 8TB
Hm... it seems to me that in the lstdvd_Click routine, when you try to access anything from rsMember, you have already (as mentioned in my prior post) moved past the end of this recordset, and so will produce an error.
Jul 6 '07 #7
pureenhanoi
175 100+
OK. What I meant was...
I'm doing a school project. I'm making a system software for an internet cafe. For this I'm using Visual basic and Microsoft Access. I'm using this code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.  
  3.     Set dbMyDb = OpenDatabase("C:\Documents and Settings\Shahidul\My Documents\Computing Project\Database.mdb")
  4.     Set rsDvd = dbMyDb.OpenRecordset("DVD", dbOpenDynaset)
  5.  
  6. If Not rsDvd.EOF Then rsDvd.MoveFirst
  7. Do While Not rsDvd.EOF
  8.     lstdvd.AddItem rsDvd!DVD_no
  9.     lstdvd.List(lstdvd.NewIndex) = rsDvd!Name
  10.     rsDvd.MoveNext
  11. Loop
  12.  
  13.     Set rsMember = dbMyDb.OpenRecordset("Member", dbOpenDynaset)
  14.  
  15. If Not rsMember.EOF Then rsMember.MoveFirst
  16.  
  17. Do Until rsMember.EOF
  18.     rsMember.MoveNext
  19. Loop
  20.  
  21.  
  22. End Sub
  23.  
  24. Private Sub lstdvd_Click()
  25.  
  26. Set rsDvd = dbMyDb.OpenRecordset("DVD", dbOpenDynaset)
  27.  
  28.     txtdvdno.Text = rsDvd!DVD_no
  29.     txtname.Text = rsDvd!Name
  30.     txtTakendate.Text = rsDvd!Date_taken
  31.     txtReturndate.Text = rsDvd!Date_return
  32.     txtrent.Text = rsDvd!Renting_cost
  33.     txtbuy.Text = rsDvd!Buying_cost
  34.     txtmemberid.Text = rsMember!Member_id
  35.     txtFname.Text = rsMember!First_name
  36.     txtLname.Text = rsMember!Last_name
  37. End Sub
  38.  
So when I click on the list box selecting one data should be taken from the DVD table and show in the specified box and data from the Member table should do the same in their textboxes. But I get an error NO CURRENT RECORD or some other error after I've tried to fix it. Have you got any solutions for this please?
let see
Expand|Select|Wrap|Line Numbers
  1.     Set rsDvd = dbMyDb.OpenRecordset("DVD", dbOpenDynaset)
  2. ...............
  3.    Set rsMember = dbMyDb.OpenRecordset("Member", dbOpenDynaset)
  4.  
did u mean that DVD and Member are tables?
Expand|Select|Wrap|Line Numbers
  1. Set rsMember = dbMyDb.OpenRecordset("Member", dbOpenDynaset)    
  2. If Not rsMember.EOF Then rsMember.MoveFirst
  3. Do Until rsMember.EOF
  4.     rsMember.MoveNext
  5. Loop
  6.  
what does this code do?
Expand|Select|Wrap|Line Numbers
  1. Private Sub lstdvd_Click()
  2. Set rsDvd = dbMyDb.OpenRecordset("DVD", dbOpenDynaset)
  3.     txtdvdno.Text = rsDvd!DVD_no
  4.     txtname.Text = rsDvd!Name
  5.     txtTakendate.Text = rsDvd!Date_taken
  6.     txtReturndate.Text = rsDvd!Date_return
  7.     txtrent.Text = rsDvd!Renting_cost
  8.     txtbuy.Text = rsDvd!Buying_cost
  9.     txtmemberid.Text = rsMember!Member_id
  10.     txtFname.Text = rsMember!First_name
  11.     txtLname.Text = rsMember!Last_name
  12. End Sub
  13.  
here, u havent open rsMember yet. So, u cannot access to its rows. If u declare rsMember as a local varriable. It may havent been dispose at this possition but u moved its cursor to EOF at Do...Loop.
i dont know the relation between DVD and Member table . If it has , u should make a Query to select datas on these two tables first. And then u can open this Query (as the same as open the table) to get datas. Otherwise, u donot have reason to get datas of two table at the same possition.
if it's not a private, show me ur database structure and let me know what do u need for this program.
Jul 6 '07 #8

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

Similar topics

5
by: Carlos Ribeiro | last post by:
Hello all, I'm posting this to the list with the intention to form a group of people interested in this type of solution. I'm not going to spam the list with it, unless for occasional and...
3
by: Random Person | last post by:
Does anyone know how to use VBA to relink tables between two MS Access databases? We have two databases, one with VBA code and the other with data tables. The tables are referenced by linked...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
1
by: Daveyk0 | last post by:
Hello there, I have a front end database that I have recently made very many changes to to allow off-line use. I keep copies of the databases on my hard drive and link to them rather than the...
8
by: sara | last post by:
I am learning Access and programming. I wanted to have the user select the departments for an ad from the list of all departments. Found code (that I could understand) on this site, and it works....
3
by: chellappa | last post by:
hi this simple sorting , but it not running...please correect error for sorting using pointer or linked list sorting , i did value sorting in linkedlist please correct error #include<stdio.h>...
0
by: g18c | last post by:
Hi, i have a class which has a property which is a list of items. I want to be able to set this item list from a set of items (in this case list2 as shown in the code below) from a drop down combo...
6
by: Julia | last post by:
I am trying to sort a linked list using insertion sort. I have seen a lot of ways to get around this problem but no time-efficient and space-efficient solution. This is what I have so far: ...
10
by: AZRebelCowgirl73 | last post by:
This is what I have so far: My program! import java.util.*; import java.lang.*; import java.io.*; import ch06.lists.*; public class UIandDB {
10
by: Debajit Adhikary | last post by:
I have two lists: a = b = What I'd like to do is append all of the elements of b at the end of a, so that a looks like: a =
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
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...

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.