473,394 Members | 1,702 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.

VB6 with database access

Hi,
Could you please tell me why iam getting this error (Run time error '424' object required)
Im trying to display data from 3 tables(customer02,account03 and transaction02) using a grid for the transaction02 data.
Thank you.
Shananne
Expand|Select|Wrap|Line Numbers
  1. Dim db1 As DAO.database
  2. Dim rs1 As DAO.Recordset 'Account02
  3. Dim rs2 As DAO.Recordset ' Transaction
  4.  
  5. Private Sub Form_Load()
  6. Show
  7. 'set up the grid
  8. Grid1.Row = 0
  9. Grid1.ColWidth(0) = 1500
  10. Grid1.ColWidth(1) = 850
  11. Grid1.ColWidth(2) = 800
  12. Grid1.Col = 0
  13. Grid1.Text = "Transaction_no"
  14. Grid1.Col = 1
  15. Grid1.Col = "Transaction date"
  16. Grid1.Col = 2
  17. Grid1.Text = "Amount"
  18. 'Open the database
  19. Set db1 = OpenDatabase("Bank.mdb")
  20. 'Database is in same folder as this application.
  21. 'create Account02 recordeset rs1
  22. x$ = "Select customer02.*,account_no,date,amount"
  23. x$ = x$ & "from Customer02, Account02"
  24. x$ = x$ & "where C_no = account_no"
  25. x$ = x$ & "order by C_no, date"
  26. Set rs1 = db1.OpenRecordset(x$, dbOpenSnapshot)
  27. display_customer02_account02_transaction02 'call the subroutine
  28. End Sub
  29.  
  30. Private Sub display_customer02_account02_transaction02()
  31. Picture1.Cls
  32. Picture1.Print "Bank no: " & rsMyRS1!C_no
  33. Picture1.Print rs1!Title & " " & rs1!initials & " " & rs1!surname
  34. Picture1.Print rs1!city
  35. Picture1.Print rs1!postc
  36. Label1.Caption = rs1!Account_no
  37. Label2.Caption = rs1!Date
  38. 'Clear the grid
  39. For i = 1 To 10
  40. Grid1.Row = i
  41. For j = 0 To 2
  42. Grid1.Col = j
  43. Grid1.Text = ""
  44. Next j
  45. Next i
  46. 'Retrieve set of transactions02 for current account_no
  47. x$ = "select transaction_no, transaction date, amount"
  48. x$ = x$ & "from Transaction02"
  49. x$ = x$ & "where Account_no ="
  50. x$ = x$ & rs1!Account_no
  51. Set rs2 = db1.OpenRecordset(x$, dbOpenSnapshot)
  52. 'Display transactions
  53. If rs2.RecordCount > 0 Then
  54. Grid1.Row = 0
  55. Do While Not rs2.EOF
  56. Grid1.Row = Grid1.Row + 1
  57. Grid1.Col = 0
  58. Grid1.Text = rs2!transaction_no
  59. Grid1.Col = 1
  60. Grid1.Text = rs2!Transaction = 2
  61. Grid1.Text = rs2!amount
  62. rs2.MoveNext
  63. Loop
  64. End If
  65. End Sub
  66. Private Sub Command1_Click()
  67. If rs1.EOF Then Exit Sub
  68. rs1.MoveNext
  69. If rs1.EOF Then Exit Sub
  70. 'Display current account02 details
  71. display_customer02_account02_transaction02 'call this procedure subroutine
  72. End Sub
  73.  
Mar 19 '08 #1
2 1802
lotus18
866 512MB
Expand|Select|Wrap|Line Numbers
  1. Dim db1 As DAO.database
  2. Dim rs1 As DAO.Recordset 'Account02
  3. Dim rs2 As DAO.Recordset ' Transaction
  4.  
  5. Private Sub Form_Load()
  6. Show
  7. 'set up the grid
  8. Grid1.Row = 0
  9. Grid1.ColWidth(0) = 1500
  10. Grid1.ColWidth(1) = 850
  11. Grid1.ColWidth(2) = 800
  12. Grid1.Col = 0
  13. Grid1.Text = "Transaction_no"
  14. Grid1.Col = 1
  15. Grid1.Col = "Transaction date"
  16. Grid1.Col = 2
  17. Grid1.Text = "Amount"
  18. 'Open the database
  19. Set db1 = OpenDatabase("Bank.mdb")
  20. 'Database is in same folder as this application.
  21. 'create Account02 recordeset rs1
  22. x$ = "Select customer02.*,account_no,date,amount"
  23. x$ = x$ & "from Customer02, Account02"
  24. x$ = x$ & "where C_no = account_no"
  25. x$ = x$ & "order by C_no, date"
  26. Set rs1 = db1.OpenRecordset(x$, dbOpenSnapshot)
  27. display_customer02_account02_transaction02 'call the subroutine
  28. End Sub
  29.  
  30. Private Sub display_customer02_account02_transaction02()
  31. Picture1.Cls
  32. Picture1.Print "Bank no: " & rsMyRS1!C_no
  33. Picture1.Print rs1!Title & " " & rs1!initials & " " & rs1!surname
  34. Picture1.Print rs1!city
  35. Picture1.Print rs1!postc
  36. Label1.Caption = rs1!Account_no
  37. Label2.Caption = rs1!Date
  38. 'Clear the grid
  39. For i = 1 To 10
  40. Grid1.Row = i
  41. For j = 0 To 2
  42. Grid1.Col = j
  43. Grid1.Text = ""
  44. Next j
  45. Next i
  46. 'Retrieve set of transactions02 for current account_no
  47. x$ = "select transaction_no, transaction date, amount"
  48. x$ = x$ & "from Transaction02"
  49. x$ = x$ & "where Account_no ="
  50. x$ = x$ & rs1!Account_no
  51. Set rs2 = db1.OpenRecordset(x$, dbOpenSnapshot)
  52. 'Display transactions
  53. If rs2.RecordCount > 0 Then
  54. Grid1.Row = 0
  55. Do While Not rs2.EOF
  56. Grid1.Row = Grid1.Row + 1
  57. Grid1.Col = 0
  58. Grid1.Text = rs2!transaction_no
  59. Grid1.Col = 1
  60. Grid1.Text = rs2!Transaction = 2
  61. Grid1.Text = rs2!amount
  62. rs2.MoveNext
  63. Loop
  64. End If
  65. End Sub
  66. Private Sub Command1_Click()
  67. If rs1.EOF Then Exit Sub
  68. rs1.MoveNext
  69. If rs1.EOF Then Exit Sub
  70. 'Display current account02 details
  71. display_customer02_account02_transaction02 'call this procedure subroutine
  72. End Sub
Specify what line that error occurs. I have no idea with DAO, but I guess you need to add the keyword New
Expand|Select|Wrap|Line Numbers
  1. Dim db1 As New DAO.database
  2.  Dim rs1 As New DAO.Recordset 'Account02
  3.  Dim rs2 As New DAO.Recordset ' Transaction
Ooops, at line 37, you need to replace the name of your field. (Note: Date is a datatype) : )
Mar 20 '08 #2
Hi
Just call this line in this function "display_customer02_account02_transaction02()" instead of Form load event.

Set rs1 = db1.OpenRecordset(x$, dbOpenSnapshot)

It will work.

musai.
Mar 20 '08 #3

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

Similar topics

6
by: Sarah Tanembaum | last post by:
I was wondering if it is possible to create a secure database system using RDBMS(MySQL, Oracle, SQL*Server, PostgreSQL etc) and web scripting/programming language(Perl, PHP, Ruby, Java, ASP, etc)...
3
by: cooldv | last post by:
i am running a website on Windows 2000 server with ASP 3 webpages and Access 2000 database. (with a hosting company) traffic is slow at this time but expect to grow. lately i have been reading...
10
by: MHenry | last post by:
Hi, We were going merrily along for 6 years using this database to record all client checks that came into our office, including information about what the checks were for. Suddenly, network...
5
by: premmehrotra | last post by:
I currently have a multi-user access database which is put on a shared drive L: on a Windows Servers. Entire database is one file premdb.mdb. Users access this database from their laptops....
8
by: John Baker | last post by:
Hi: I am URGENTLY in need of some book or web site OR tool that will help me integrate a relatively simple access application into a web page or pages. This is a time recording system (by...
1
by: Claus Haslauer | last post by:
Hi, firstly, I am new to access03 and server03 Originally, I had written an access 2002 database. Then, we transferred (for another reason) to server 2003. Then, we got access 2003. Then I...
15
by: philip | last post by:
On a form, I have a datagridview. This datagridview is constructed on a dataset filled by a tableadapter. The table adapter do very well what it must do when filling dataset. Insertions,...
7
by: Allison | last post by:
Hi -- we are a small manufacturing looking for a multi-user database to take customer orders (nothing too complicated, with 3 users total). We think we should be using Access, but are wondering...
18
by: surfrat_ | last post by:
Hi, I am having the following problems in getting Microsoft Visual Studio 2005 Professional to link to an Access .mdb database. Please help me to sort this out. Problem 1: The Microsoft...
21
by: nihad.nasim | last post by:
Hi there, I have a database in Access that I need on the web. The web page should connect to the database and write records for certain tables and view records for others. I want to know a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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.