! |
Sub test() ' ! DoCmd.SetWarnings True Dim dbs As Database, rstList As Recordset, fldID As Field, fldName As Field Set dbs = CurrentDb ' . Dim txtSQL As String On Error Resume Next ' CurrentDb.Execute "Drop table test_" CurrentDb.Execute "Drop table q_" On Error GoTo 0 ' CurrentDb.Execute "Create table test_ (idclient int, Client string(72))" ' Set rstList = dbs.OpenRecordset("test_") 'Set fldID = rstList.Fields!idclient 'Set fldName = rstList.Fields!client 'rstList.MoveFirst With rstList '.Edit .AddNew .Fields("idclient") = 0 .Fields("client") = " -" .Update .Close End With tbl_Name = "test_" ' c client txtSQL = "SELECT Count([" & tbl_Name & "].CLIENT) As [COUNT] FROM [" & tbl_Name & "] WHERE ((([" & tbl_Name & "].CLIENT) Like (" & """" & "*" & """" & ")))" '--- . Dim FileName Dim iFileNum As Integer iFileNum = FreeFile sFileName = "D:\1" 'Will write file Open sFileName For Append As iFileNum Print #iFileNum, txtSQL Close iFileNum '---- '!!! 1, - ! :-((( a = CurrentProject.Connection.Execute(txtSQL).Fields(0) ' . Set MyQuery = dbs.CreateQueryDef("q_", txtSQL) ' 1 DoCmd.OpenQuery "q_", acViewNormal, acEdit End Sub