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(customer 02,account03 and transaction02) using a grid for the transaction02 data.
Thank you.
Shananne
[code=vb]
Dim db1 As DAO.database
Dim rs1 As DAO.Recordset 'Account02
Dim rs2 As DAO.Recordset ' Transaction
Private Sub Form_Load()
Show
'set up the grid
Grid1.Row = 0
Grid1.ColWidth( 0) = 1500
Grid1.ColWidth( 1) = 850
Grid1.ColWidth( 2) = 800
Grid1.Col = 0
Grid1.Text = "Transaction_no "
Grid1.Col = 1
Grid1.Col = "Transactio n date"
Grid1.Col = 2
Grid1.Text = "Amount"
'Open the database
Set db1 = OpenDatabase("B ank.mdb")
'Database is in same folder as this application.
'create Account02 recordeset rs1
x$ = "Select customer02.*,ac count_no,date,a mount"
x$ = x$ & "from Customer02, Account02"
x$ = x$ & "where C_no = account_no"
x$ = x$ & "order by C_no, date"
Set rs1 = db1.OpenRecords et(x$, dbOpenSnapshot)
display_custome r02_account02_t ransaction02 'call the subroutine
End Sub
Private Sub display_custome r02_account02_t ransaction02()
Picture1.Cls
Picture1.Print "Bank no: " & rsMyRS1!C_no
Picture1.Print rs1!Title & " " & rs1!initials & " " & rs1!surname
Picture1.Print rs1!city
Picture1.Print rs1!postc
Label1.Caption = rs1!Account_no
Label2.Caption = rs1!Date
'Clear the grid
For i = 1 To 10
Grid1.Row = i
For j = 0 To 2
Grid1.Col = j
Grid1.Text = ""
Next j
Next i
'Retrieve set of transactions02 for current account_no
x$ = "select transaction_no, transaction date, amount"
x$ = x$ & "from Transaction02"
x$ = x$ & "where Account_no ="
x$ = x$ & rs1!Account_no
Set rs2 = db1.OpenRecords et(x$, dbOpenSnapshot)
'Display transactions
If rs2.RecordCount > 0 Then
Grid1.Row = 0
Do While Not rs2.EOF
Grid1.Row = Grid1.Row + 1
Grid1.Col = 0
Grid1.Text = rs2!transaction _no
Grid1.Col = 1
Grid1.Text = rs2!Transaction = 2
Grid1.Text = rs2!amount
rs2.MoveNext
Loop
End If
End Sub
Private Sub Command1_Click( )
If rs1.EOF Then Exit Sub
rs1.MoveNext
If rs1.EOF Then Exit Sub
'Display current account02 details
display_custome r02_account02_t ransaction02 'call this procedure subroutine
End Sub
[/code]
Could you please tell me why iam getting this error (Run time error '424' object required)
Im trying to display data from 3 tables(customer 02,account03 and transaction02) using a grid for the transaction02 data.
Thank you.
Shananne
[code=vb]
Dim db1 As DAO.database
Dim rs1 As DAO.Recordset 'Account02
Dim rs2 As DAO.Recordset ' Transaction
Private Sub Form_Load()
Show
'set up the grid
Grid1.Row = 0
Grid1.ColWidth( 0) = 1500
Grid1.ColWidth( 1) = 850
Grid1.ColWidth( 2) = 800
Grid1.Col = 0
Grid1.Text = "Transaction_no "
Grid1.Col = 1
Grid1.Col = "Transactio n date"
Grid1.Col = 2
Grid1.Text = "Amount"
'Open the database
Set db1 = OpenDatabase("B ank.mdb")
'Database is in same folder as this application.
'create Account02 recordeset rs1
x$ = "Select customer02.*,ac count_no,date,a mount"
x$ = x$ & "from Customer02, Account02"
x$ = x$ & "where C_no = account_no"
x$ = x$ & "order by C_no, date"
Set rs1 = db1.OpenRecords et(x$, dbOpenSnapshot)
display_custome r02_account02_t ransaction02 'call the subroutine
End Sub
Private Sub display_custome r02_account02_t ransaction02()
Picture1.Cls
Picture1.Print "Bank no: " & rsMyRS1!C_no
Picture1.Print rs1!Title & " " & rs1!initials & " " & rs1!surname
Picture1.Print rs1!city
Picture1.Print rs1!postc
Label1.Caption = rs1!Account_no
Label2.Caption = rs1!Date
'Clear the grid
For i = 1 To 10
Grid1.Row = i
For j = 0 To 2
Grid1.Col = j
Grid1.Text = ""
Next j
Next i
'Retrieve set of transactions02 for current account_no
x$ = "select transaction_no, transaction date, amount"
x$ = x$ & "from Transaction02"
x$ = x$ & "where Account_no ="
x$ = x$ & rs1!Account_no
Set rs2 = db1.OpenRecords et(x$, dbOpenSnapshot)
'Display transactions
If rs2.RecordCount > 0 Then
Grid1.Row = 0
Do While Not rs2.EOF
Grid1.Row = Grid1.Row + 1
Grid1.Col = 0
Grid1.Text = rs2!transaction _no
Grid1.Col = 1
Grid1.Text = rs2!Transaction = 2
Grid1.Text = rs2!amount
rs2.MoveNext
Loop
End If
End Sub
Private Sub Command1_Click( )
If rs1.EOF Then Exit Sub
rs1.MoveNext
If rs1.EOF Then Exit Sub
'Display current account02 details
display_custome r02_account02_t ransaction02 'call this procedure subroutine
End Sub
[/code]
Comment