O
OldEnough
I am new to ADO and would appreciate any suggestions. I have a form that
allows users to select criteria to shape a query against a table of service
records. Based on the selection criteria the search then inserts selected
records into a local table. At this point the selection form is closed and a
form based on a query against the table is opened to review the selected
records. The query doesn't work when opened by the calling form, but if the
table is opened the records are there, and if the form is then reopened the
records appear. Thanks for looking at this.
relevant code below:
'Called by buttonclick event
Dim IntPos As Integer
Dim IntPos1 As Integer
Dim AccessConnect As String
'These lines identify current location and name of database
IntPos = InStrRev(getdbPath(), "\", -1, vbTextCompare) - 1
CFPath = Left(getdbPath(), IntPos)
MyStr = MyAppPath()
AccessConnect = "Driver={Microsoft Access Driver (*.mdb)};Dbq=" & MyStr
& "; DefaultDir=" & CFPath & ";" & _
"Uid=Admin;Pwd=;"
Dim strSQL As String
Dim oCmd As Command
Set oCmd = New Command
Dim oRS As New ADODB.Recordset
Dim cnn As New ADODB.Connection
MyStr = CurrentDb.Name
'This is the shaped SQL criteria string to insert the selected records
strSQL = strSQL1 & MyStr & strSQL2
cnn.ConnectionString = AccessConnect
cnn.Open
With oCmd
.CommandText = strSQL
.CommandType = adCmdText
.ActiveConnection = cnn
Set oRS = .Execute
End With
Set oRS = Nothing
Set oCmd = Nothing
cnn.Close
Set cnn = Nothing
allows users to select criteria to shape a query against a table of service
records. Based on the selection criteria the search then inserts selected
records into a local table. At this point the selection form is closed and a
form based on a query against the table is opened to review the selected
records. The query doesn't work when opened by the calling form, but if the
table is opened the records are there, and if the form is then reopened the
records appear. Thanks for looking at this.
relevant code below:
'Called by buttonclick event
Dim IntPos As Integer
Dim IntPos1 As Integer
Dim AccessConnect As String
'These lines identify current location and name of database
IntPos = InStrRev(getdbPath(), "\", -1, vbTextCompare) - 1
CFPath = Left(getdbPath(), IntPos)
MyStr = MyAppPath()
AccessConnect = "Driver={Microsoft Access Driver (*.mdb)};Dbq=" & MyStr
& "; DefaultDir=" & CFPath & ";" & _
"Uid=Admin;Pwd=;"
Dim strSQL As String
Dim oCmd As Command
Set oCmd = New Command
Dim oRS As New ADODB.Recordset
Dim cnn As New ADODB.Connection
MyStr = CurrentDb.Name
'This is the shaped SQL criteria string to insert the selected records
strSQL = strSQL1 & MyStr & strSQL2
cnn.ConnectionString = AccessConnect
cnn.Open
With oCmd
.CommandText = strSQL
.CommandType = adCmdText
.ActiveConnection = cnn
Set oRS = .Execute
End With
Set oRS = Nothing
Set oCmd = Nothing
cnn.Close
Set cnn = Nothing