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

Passing Recordsets

Hi
I'm having a problem with my program, basically I am trying to query two Access tables contained in the same database to display various results but I cant work out once the user as input a day (from tblbookings) and a room capacity (from tblrooms) how to display them both together. Here is the program:

Expand|Select|Wrap|Line Numbers
  1. Sub testsearchAccessdata()
  2. Dim cn1 As New ADODB.Connection
  3. Dim cn2 As New ADODB.Connection
  4. Dim rs1 As New ADODB.Recordset
  5. Dim rs2 As New ADODB.Recordset
  6. Dim Exvisual As Workbook
  7. Dim row As Integer
  8. Dim sht As String
  9.  
  10.  
  11. Set Exvisual = GetObject("C:\Assignment\av.xls")
  12.  
  13. With cn1
  14.   .Provider = "Microsoft.Jet.OLEDB.4.0"
  15.   .ConnectionString = "Data Source=C:\Assignment\roomdata.mdb;Persist Security Info=False"
  16.   .Open
  17. End With
  18.  
  19.  
  20. With rs1
  21.       .ActiveConnection = cn1
  22.       .Source = "select * from tblrooms where capacity <= " & Cells(5, 2) & " "
  23.       .Open
  24.  
  25.  End With
  26.  
  27. row = 8
  28. While Not rs1.EOF
  29.       Cells(row, 1) = rs1!RoomCode
  30.       Cells(row, 2) = rs1![Campus]
  31.       Cells(row, 3) = rs1![capacity]
  32.       row = row + 1
  33.       rs1.MoveNext
  34.  
  35.  
  36. With cn2
  37.   .Provider = "Microsoft.Jet.OLEDB.4.0"
  38.   .ConnectionString = "Data Source=C:\Assignment\roomdata.mdb;Persist Security Info=False"
  39.   .Open
  40.  End With
  41.  
  42. With rs2
  43.       .ActiveConnection = cn2
  44.       .Source = "select * from tblbookings where [roomcode] = '" & Cells(row, 1) & "'"
  45.       .Open
  46. End With
  47.  
  48.  
  49. While Not rs2.EOF
  50. '      Cells(row, 4) = rs2![activity name]
  51. '      Cells(row, 5) = rs2![Description]
  52. '     Cells(row, 6) = rs2!Campus
  53.        Cells(row, 4) = rs2![Day]
  54.       row = row + 1
  55.       rs2.MoveNext
  56. Wend
  57. Set rs2 = Nothing
  58. Set cn2 = Nothing
  59.  
  60.  
  61. Wend
  62.  
  63. Set rs1 = Nothing
  64. Set cn1 = Nothing
  65.  
  66.  
  67. End Sub
Mar 13 '08 #1
1 840
mafaisal
142 100+
Hello
I think both of table contain roomcode then change the query to Following way
Expand|Select|Wrap|Line Numbers
  1. With rs1
  2.       .ActiveConnection = cn1
  3.       .Source = "select a.*,b.* from tblrooms a, tblbookings b where a.capacity <= " & Cells(5, 2) & " And a.RoomCode = b.RoomCode  "
  4.       .Open
  5.  
  6.  End With
  7.  
  8.  
Then There is no need of sec query

Try

Faisal
Mar 23 '08 #2

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

Similar topics

0
by: Johan Lachonius | last post by:
Hi, I'm using a "classic" asp-page and a .net-component which I want to call passing a Recordset as a parameter. I have a reference to ADODB in the .net component which should supply a COM...
27
by: Oscar | last post by:
I am looking for a way to pass an ADO recordset that has been retrieved in an ASP page to another HTML-page. Is there someone who can provide me with a small sample or a link to see how this is...
0
by: Phill | last post by:
Is there a simple way to pass a parameter to an ADO recordset instead of using a hard coded where statement like below(something like forms!aaa!fieldname). I've done a fair bit of searching but...
6
by: Steve Jorgensen | last post by:
I keep having problems in which ADO disconnected recordset work under some circumstances, but lose all their data at other times, having no rows or fields, though the recordset object still exists....
2
by: Pieter Linden | last post by:
The answer to this one is probably "test it yourself and find out!", but I'll ask anyway. Pursuant to my previous question - sending separate recordsets to Word using the CreateTableFromRecordset...
1
by: lakshmi | last post by:
Hi all, I recently rewrote a data intensive C++ program in C#. The C++ program was traversing 3 recordsets that were all open at the same time. I replaced those 3 recordsets with 3 .NET data...
16
by: Randy Harris | last post by:
I was inspired by the recent discussion of returning multiple recordsets to ADO from a stored procedure. (Amazed is probably more accurate). I asked about how to accomplish same with Oracle and...
4
by: mrmagoo | last post by:
I'm building a vb.net Forms project that is getting data from a SQL Server database. One of the main goals of the project is to be really responsive to events, such as textbox change events. I...
2
by: JW | last post by:
I created a dll control which utilizes (among other things) ADO recordsets. The control properly reads the database catalog and can pull an empty recordset, but when passing records to a listform...
4
by: rdemyan via AccessMonster.com | last post by:
Can someone help me with creating code that will look for DAO recordsets in modules and then check to see if the recordset is also closed in the module. All of my recordsets are of the form rs*...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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
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...

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.