View Single Post
  #1 (permalink)  
Old March 13th, 2006, 07:26 PM
Subuana Subuana is offline
Authorized User
Join Date: Mar 2006
Location: London, , United Kingdom.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Query to extract data from 2 tables of .mdb file


i m trying to extract data from two different tables in same .mdb file where two tables are: StudentProfile and Accounts
mdldb is name of module where i've connected my vb with database
srchAccounts is the form where user enters student ID to search account info of that student.
my code is as follows:

Private Sub Form_Load()
Dim a As Integer

a = Val(SrchAccounts.txtEnterID.Text)

txtID.Text = a
cmbInstall.AddItem (One)
cmbInstall.AddItem (Two)
cmbInstall.AddItem (Three)
cmbInstall.AddItem (Four)
cmbInstall.Text = Two

Dim sql As String
Dim rs As New ADODB.Recordset
'On Error GoTo err1
Set rs = mdldb.conn.Execute("select sp.FirstName, sp.Course, sp.Semester, ac.TotalFee, ac.Installments, ac.AmountsPaid, ac.DateOfPay, ac.DuesRemaining, ac.DueDate from Accounts ac, StudentProfile sp where sp.StudentID = ac.StudentID and sp.StudentID= " & a & "") 'error is here is sql query, it says type mismatch in criteria expression

txtStdName.Text = rs!FirstName
txtCourseName.Text = rs!Course
txtCohort.Text = rs!Semester
txtFee.Text = rs!TotalFee
cmbInstall.Text = rs!Installments
txtPaid.Text = rs!AmountsPaid
txtDateOfPay = rs!DateOfPay
txtDuesRem = rs!DuesRemaining
txtDueDate = rs!DueDate

End Sub

help me plz

Reply With Quote