jaji2000
07-11-2006, 01:40 AM
Hello,
I'll let this be the dumb questions of the year (it's pass 2:00 am)..
All I'm trying to do is run an append query that I have in MS Access from VB6. I thought this would be just as simple as VBA (docmd.openquery), but obviously, I'm dead wrong.
I already have the connection and everything, but I guess I'm trying to find the easiest way of simply running a query from MS Access using VB6 (ADO).
I would appreciate any feedback ( I was thinking adodb.command??). Thanks.
This is what I have..
Public Sub ConnectMonthlyPhones()
Public cnnMonthlyPhones As New ADODB.Connection
If cnnMonthlyPhones.State = 1 Then Exit Sub 'MS Access DB already connected
cnnMonthlyPhones.ConnectionString = "Provider=Microsoft.jet.OLEDB.4.0;" _
& "Data Source=" & "C:\Database\RS_PhoneList.mdb" & ";Persist Security Info=False"
cnnMonthlyPhones.Open
End Sub
Public recPhones As New ADODB.Recordset
Public strSQL As String
strSQL = "SELECT Phones FROM [MainList_Phones]" 'Open table
With recVDNs
.Open strSQL, cnnMonthlyPhones, adOpenKeyset, adLockOptimistic
DoEvents
.MoveFirst
Do Until recPhones.EOF = True 'Get phones from Main Phones table
If Len(recPhones!Phone) > 10 Then
Beep
recPhones.Close
MsgBox ("Record selected is not consistent with a Phone format."), vbOKOnly
Exit Sub
Else
strPhone = recPhones!Phone
lblStatus.Caption = "Getting report for Phone " & recPhones!Phone
If AppendData("Q_VDN_Avaya_AppendData") = False Then
MsgBox ("query did not run")
Beep
End If
End If
recPhones.MoveNext
Loop
End With
Public Function AppendData(strQueryName As String) As Boolean
dim recRunQuery as new ADODB.command???
If cnnMonthlyPhones.State = 0 Then 'If no connection, connect to db
Call ConnectMonthlyPhones 'Open db connection.
End If
''THIS IS WHERE I"M HAVING PROBLEMS!!
''''''here......I just want to open an append query that's already created in the database
Please use the .. tags when you post your code. Edit or reply to this post to see how.
Thank you.
I'll let this be the dumb questions of the year (it's pass 2:00 am)..
All I'm trying to do is run an append query that I have in MS Access from VB6. I thought this would be just as simple as VBA (docmd.openquery), but obviously, I'm dead wrong.
I already have the connection and everything, but I guess I'm trying to find the easiest way of simply running a query from MS Access using VB6 (ADO).
I would appreciate any feedback ( I was thinking adodb.command??). Thanks.
This is what I have..
Public Sub ConnectMonthlyPhones()
Public cnnMonthlyPhones As New ADODB.Connection
If cnnMonthlyPhones.State = 1 Then Exit Sub 'MS Access DB already connected
cnnMonthlyPhones.ConnectionString = "Provider=Microsoft.jet.OLEDB.4.0;" _
& "Data Source=" & "C:\Database\RS_PhoneList.mdb" & ";Persist Security Info=False"
cnnMonthlyPhones.Open
End Sub
Public recPhones As New ADODB.Recordset
Public strSQL As String
strSQL = "SELECT Phones FROM [MainList_Phones]" 'Open table
With recVDNs
.Open strSQL, cnnMonthlyPhones, adOpenKeyset, adLockOptimistic
DoEvents
.MoveFirst
Do Until recPhones.EOF = True 'Get phones from Main Phones table
If Len(recPhones!Phone) > 10 Then
Beep
recPhones.Close
MsgBox ("Record selected is not consistent with a Phone format."), vbOKOnly
Exit Sub
Else
strPhone = recPhones!Phone
lblStatus.Caption = "Getting report for Phone " & recPhones!Phone
If AppendData("Q_VDN_Avaya_AppendData") = False Then
MsgBox ("query did not run")
Beep
End If
End If
recPhones.MoveNext
Loop
End With
Public Function AppendData(strQueryName As String) As Boolean
dim recRunQuery as new ADODB.command???
If cnnMonthlyPhones.State = 0 Then 'If no connection, connect to db
Call ConnectMonthlyPhones 'Open db connection.
End If
''THIS IS WHERE I"M HAVING PROBLEMS!!
''''''here......I just want to open an append query that's already created in the database
Please use the .. tags when you post your code. Edit or reply to this post to see how.
Thank you.