VB 6.0 - How to create query in access using vb6 0

Asked By CHANDU V on 04-Jul-06 03:12 AM

1.how to create query in access using vb6.0 through ADO's. 
    without open mdb file how to create query

2. how to display access report through vb 6.0.

anybody help me.

thanks in advance

re - Asked By Rupali Randhave Kolhe on 04-Jul-06 05:06 AM

Create query in access:

Here is how to create a temporary QueryDef: 
Dim db as Database 

Sub QDExample() 

Dim qd as QueryDef 
Dim pramA as Parameter 
Dim pramB as Parameter 
Dim SQL as String 

SQL = SQL & "YourVarB INTEGER; " 
SQL = SQL & "SELECT fieldA, 
SQL = SQL & "[YourVarA] as fieldB " 
SQL = SQL & "INTO temptable " 
SQL = SQL & "FROM [your table] " 
SQL = SQL & "WHERE thisfield = [YourVarB] " 

Set qd = db.CreateQueryDef("",SQL) 
Set pramA = qd!YourVarA 
Set pramB = qd!YourVarB 

pramA = "A string" 
pramB = 555 



End Sub 

If you have a Access Database with an existing QueryDef then do this 

Set qd = db.QueryDefs("<the name of the querydef>") 

<<<To delete this QueryDef>>> 
db.QueryDefs.Delete qd.Name 

Hope this helps,

Open/Print report - Asked By Rupali Randhave Kolhe on 04-Jul-06 05:08 AM


Print a Report and - Asked By Ryu Russell on 04-Jul-06 05:13 AM

open a Form contained in an Access Database.

'API Declarations 
Option Explicit

'API Declarations
Private Declare Function ShowWindow Lib "user32.dll" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

'API Message Constants
Private Const SW_MAXIMIZE = 3
Private Const SW_NORMAL = 1 
'add the Microsoft Access 8.0 Object Library to the project references...Create a Form with three Command Buttons and enjoy with this code
'Create a new Access Instance
Dim appAccess As New Access.Application

Public Sub MaximizeAccess()
    'Maximize Access Application
    Dim hWnd As Long

    hWnd = FindWindow("OMain", "Microsoft Access")
    If hWnd <> 0 Then
        ShowWindow hWnd, SW_NORMAL
        ShowWindow hWnd, SW_MAXIMIZE
    End If
End Sub

'Open an Access Form
Private Sub Command1_Click()
    appAccess.DoCmd.OpenForm "Categories", acNormal, , , , acDialog
End Sub

'Print an Access Report
Private Sub Command2_Click()
    appAccess.DoCmd.OpenReport "Catalog", acViewNormal
End Sub

Private Sub Command3_Click()
End Sub

'Open a Database
Private Sub Form_Load()
    appAccess.OpenCurrentDatabase "C:\Program Files\Microsoft Visual Studio\VB98\nwind.mdb", True
End Sub

'Close the database and the Access Instance
Private Sub Form_Unload(Cancel As Integer)
    On Error Resume Next
    appAccess.DoCmd.Quit acQuitSaveNone
End Sub 

Hope this will help.
error occured - Asked By CHANDU V on 04-Jul-06 07:14 AM

I do this type process, there is an error occured ie. unrecognised database format. 

so, there is any possibility using ADO's to create query in access database. 

Oracle - Asked By mohd jahed on 05-Jul-06 03:51 AM
How many type of databases are there? briefly describe each one's functions.
What is Groupby clause? Whether we can restrict columns with the help of groupby clause.