PDA

Click to See Complete Forum and Search --> : Open Access Query


alwsid
Apr 6th, 2000, 03:47 PM
Hello...

How to open and use the Access Query from VB6.
I mean I want use that for my application.

Forest Dragon
Apr 6th, 2000, 07:26 PM
DAO:

Dim DB As Database, RecSet As Recordset

Set DB=DBEngine.Workspaces(0).OpenDatabase(DatabaseName)
Set RecSet=DB.OpenRecordset(QueryName)

ADO:

Dim RecSet As Recordset

Set RecSet=New Recordset
RecSet.Source=QueryName
Set RecSet.ActiveConnection=ConnectionName
RecSet.Open

If you need more details, tell me!

alwsid
Apr 7th, 2000, 08:55 AM
Thanks Forest Dragon...

One more question..
If I want to use parameter query to my report, how to do that.
Could you or someone show to me please.

waiting response.

Forest Dragon
Apr 8th, 2000, 02:22 AM
If you mean you want to use a parameter query with VB's DataReport control, you need to follow these steps:

1. Use the DataEnvironment to create the new Command object.

2. Fill the SQL sentence of the Command object. Use the "?" character instead of the parameters.
Example: SELECT * FROM Customers WHERE CustomerID=?

3. Now click the parameters tab. You will see all your parameters. You cannot add or delete parameters to the list because it counts on the SQL sentence, but you can change their names.

4. Build the DataReport and bind it to the Command object.

5. Before you display the DataReport, you need to run the Command object and give it the values of the parameters. Example: DataEnvironment1.Command1 Parameter1,Parameter2, …
You should build a form that will let the user fill the values.

6. Now you can display your DataReport by using DataReport1.Show

Good Luck!!!

alwsid
Apr 9th, 2000, 05:26 PM
Thanks Forest Dragon for your response.

I've tried like your step above, but still have a problem.
I've got error message "Parameter?_1 has no default value"

Better if you can show one example to me.

My SQL sentence :
"SELECT * FROM Customer Where CustomerID=?"
My command name=Command1
My Parameter name=Param1

LG
Apr 11th, 2000, 02:45 AM
Hi, there.

Check this:
http://support.microsoft.com/support/kb/articles/Q244/7/79.ASP?LNG=ENG&SA=ALLKB&FR=0

Larisa

alwsid
Apr 11th, 2000, 09:33 PM
Hi...LG and Forest Dragon
Thanks a lot for helping me to carry out my problem and
good luck to you all.