|
-
Apr 28th, 2005, 09:40 AM
#1
Thread Starter
Addicted Member
Query on the fly?
Hi i want to create a query on the fly. Meaning i have a query that contains, name,class,group,attend,date.... What i want to do is select a certain date from this query and put them into another query(temperary if possible). can this be done.
I'm using MS Access,VB6...
Thanking you in advance
Chris lynch
-
Apr 28th, 2005, 01:58 PM
#2
Re: Query on the fly?
How are you connectiong to your db? ADO? You can create a query dynamically and pass that in an
ADO Recordset .Open method call.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 29th, 2005, 03:21 AM
#3
Thread Starter
Addicted Member
Re: Query on the fly?
Yes I'm using ADO sorry for not mentioning it..... HAve you an example of what you said or a link... Something to get started with?
Thanks
ChrisLynch
-
Apr 29th, 2005, 07:18 AM
#4
New Member
Re: Query on the fly?
Set your report database's datasource to a recordset.
(Ex: Report.Database.SetDataSource YourRS)
-
Apr 29th, 2005, 09:19 AM
#5
Thread Starter
Addicted Member
Re: Query on the fly?
where in vb6 and then this will do what?
-
Apr 29th, 2005, 09:31 AM
#6
Re: Query on the fly?
Something like
VB Code:
Dim sSQL As String
sSQL = "SELECT name,class,group,attend,date FROM yourtable "
adoRs.Open sSQL, cnobject
'then you could insert the results of your recordset into a temp
'table to which your crystal report was bound
-
Apr 29th, 2005, 10:43 AM
#7
Thread Starter
Addicted Member
Re: Query on the fly?
I'm using an access database, is that a problem?
-
Apr 29th, 2005, 10:49 AM
#8
Re: Query on the fly?
 Originally Posted by chris lynch
I'm using an access database, is that a problem?
Nope...for years I worked on an application that used Oracle as the backend. With the code, we shipped an Access Database. This Access database had a boat load of tables in it, and each table had a Crystal Report bound to it.
When I ran a SQL query against the Oracle database, I created a recordset and feed the recordset into the appropriate Access Table, and the bound Crystal Report resulted.
Of course, prior to each run, the contents of the table was deleted before the new recordset data was inserted.
-
May 4th, 2005, 04:09 AM
#9
Thread Starter
Addicted Member
Re: Query on the fly?(Bumped)
I have that done and it just runs throught the code and nothing happens.... Is there something else i'm missing?
HI again, i have been gone awhile, i've been looking for some cod eto work with this....
Have i got it right that the following code won't show anyresults. What can i do to show the recordset on a form?
Please help please
VB Code:
Dim rs As New ADODB.Recordset
Dim myconn As New ADODB.Connection
Dim sql As String
myconn.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=MS Access Database;Initial Catalog=D:\Documents and Settings\christopher.lynch\Desktop\Complete Manual program\Manualrecords.mdb;" & " Pwd= " & Txtpassword.Text & " "
myconn.Open 'connection string'
sql = "SELECT * FROM [Total]"
If Len(TxtManualdate.Text) > 0 Then
sql = sql & " WHERE [Date] = #" & TxtManualdate.Text & "# "
Debug.Print sql
End If
rs.Open sql, myconn
Last edited by chris lynch; May 5th, 2005 at 09:42 AM.
11 is the magic number
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|