|
|
#1 |
|
Lively Member
Join Date: Aug 00
Location: South Africa
Posts: 113
![]() |
Hi all,
please leme knoe how to execute an access query from vb I need to run a make table query... sqlq = "SELECT ned_rpt_case_stats.* INTO temp " & _ " FROM ned_rpt_case_stats" thats my query now i always just put in a data structure from the toolbox and call it datSQL. then i go datsql.recordsource=sqlq... but now i need the query to actually execute from vb so that the table in access gets created thanks ina advance
__________________
You are living a pacifist dream, and if you dreaming it means you sleeping and you should damn well wake up! |
|
|
|
|
|
#2 |
|
Lively Member
Join Date: Nov 00
Posts: 82
![]() |
I'm not sure if I'm missing something here, but...
Assuming your database name is "MyDB", you can execute any valid SQL statement against the database as follows: Code:
MyDB.Execute MySQLStatement |
|
|
|
|
|
#3 |
|
Lively Member
Join Date: Aug 00
Location: South Africa
Posts: 113
![]() |
but how do i set up the database
thanks but...
please show me how to set the database up i have always used record sources and dont know how to dim the database and then show where it is attached to
__________________
You are living a pacifist dream, and if you dreaming it means you sleeping and you should damn well wake up! |
|
|
|
|
|
#4 |
|
Fanatic Member
Join Date: Jan 01
Location: Vietnam
Posts: 613
![]() |
Hi SmagO,
Please try this, I think it is what you are looking for: Code:
Dim con As ADODB.Connection
Dim cmd As ADODB.Command
Dim rs As ADODB.Recordset
Private Sub Command1_Click()
Set cmd = New ADODB.Command
With cmd
.ActiveConnection = con
.CommandType = adCmdUnknown
'execute the Invoice query
.CommandText = "Invoices"
Set rs = .Execute
End With
'testing it
Dim counter As Integer
For counter = 0 To rs.Fields.Count - 1
Debug.Print rs.Fields(counter).Value
Next
End Sub
Private Sub Form_Load()
'connect to Northwind access file
Set con = New ADODB.Connection
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\Microsoft Visual Studio\VB98\Nwind.mdb;Persist Security Info=False"
con.Open
End Sub
Regards, TheBao |
|
|
|
![]() |
|
||||||
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|