• WSsal21

    WSsal21

    @wssal21

    Viewing 15 replies - 31 through 45 (of 2,735 total)
    Author
    Replies
    • in reply to: FornAt records #1190659

      Try

      Code:
      Dim strSQL As String
      strSQL = "UPDATE MyTable SET MyField = Format(MyField, ""####"")"
      cnn.Execute strSQL
      

      where:

      MyTable is the name of the table.
      MyField is the name of the field.
      cnn is the name of the ADODB connection variable.

      But you use #### instead #0000 is the same way?

    • in reply to: create schema.ini dinamic… #1190652

      You’ll have to format the value 555 as 0555 when you add it to myvar.

      yes…. I use this myvar to write in a txt file

    • in reply to: create schema.ini dinamic… #1190648

      You can’t specify a format for individual columns in a Schema.ini file, as far as I know.

      hummmm….
      Now admit have myvar=tttt;555;65tttt;…eccc
      how to have the same var string whit format #0000 on the second element of string
      new myvar=tttt;0555;65tttt . …

    • in reply to: create schema.ini dinamic… #1190574

      Please see the explanation in the MSKB article and the example below the code.

      pERFECT, TKS!
      all work fine…

      but is possible to insert a format in column when the code write the schema.ini?
      For example the:

      Print #intFile, Col2=AGENZIA_CENTRO Text format”#0000″

    • in reply to: create schema.ini dinamic… #1190537

      See Creazione a livello di programmazione di un file schema.ini in Access 2000.

      Yes perefect! (you have understand me on fly) kiss for that.
      But how to call the function and wath is the param to call the function?
      And i can use this function in a vba for Excel macro?

    • in reply to: COUNT not blank records in a single field #1187992

      You could do something like this:

      Dim cnn As ADODB.Connection
      Dim rst As New ADODB.Recordset
      Dim strSQL As String
      Dim lngCount As Long

      Set cnn = …
      strSQL = “SELECT Count(*) As Cnt FROM [” & my_var1 & “] WHERE [” & my_var_2 & ] Is Not Null”
      rst.Open strSQL, cnn, , adLockOptimistic, adCmdText
      lngCount = rst!Cnt
      rst.Close
      Set rst = Nothing

      EXCELLENT!
      but is the fasted method?

      I want use the same code but with sql server (with ADO con) existis a fasted method for this type of database?

    • in reply to: looping in table field and return the name #1186960

      You can open a recordset rst on MyTable, then use a loop like this:

      Code:
      Dim fld As ADODB.Field
      Dim strName As String
      For Each fld In rst.Fields
        strName = fld.Name
        ...
        ...
      Next fld

      hi… is possible during this loop to know also the property of each filed?
      Similar is is numeric, double text ecc….

    • in reply to: looping in table field and return the name #1186888

      Yes. Use code like this:

      Code:
      ...
      Dim fld As ADODB.Field
      Dim strName As String
      Dim strLine As String
      Dim f As Integer
      
      ' Create text file
      f = FreeFile
      Open "C:MyFile.txt" For Output As #f
      
      For Each fld In rst.Fields
        ' Get name of field
        strName = fld.Name
        ' Append to strLine
        strLine = strLine & ";" & strName
      Next fld
      
      ' Write strLine to file, omitting the first semicolon ;
      Print #f, Mid(strLine, 2)
      
      ' Close text file
      Close #f
      ...

      wow!

      But the next prob is:
      i want to write (after this header) also the value of recordset separeted from “;” how to? i not have any idea.
      In effet i wat to loop into recorset and create the rest of CSV

    • in reply to: looping in table field and return the name #1186880

      You can open a recordset rst on MyTable, then use a loop like this:

      Code:
      Dim fld As ADODB.Field
      Dim strName As String
      For Each fld In rst.Fields
        strName = fld.Name
        ...
        ...
      Next fld

      Hi Hans…
      Based the code is possible to write into a text file similar c:myfile.txt the name of fileds separated from “;”?
      I want to use to make the header of CSV text file.

    • in reply to: speed to write in access database… #1186771

      You should only place quotes ‘ around text values. From your screenshot, I get the impression that C_OPER, TOT_OP, TOT_PZ and TOT_IMP are number or currency values, so you should not place quotes around those.

      Yes are number….
      Example for the last 3 value?

    • in reply to: speed to write in access database… #1186769

      If you’re adding a single record, you won’t notice any difference.
      A SQL statement with INSERT INTO can add many records at once, so if you need to add multiple records, executing a SQL statement will be faster.

      Error different number of fileds and value in query!!!!! why???

      Code:
      ''''''''''''''''
          Set CN1 = New ADODB.Connection
          CN1.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:EPFOperativita_Sportello_Mag_07_Oggi.mdb;"
      
      '''''''''''''''''
        
                  SQL = "INSERT INTO L1262 " & _
              "([DATA_RIF], [AGENZIA_CENTRO], [SEGM], [C_OPER], [MS],[MERC], [TOT_OPE], [TOT_PEZ], [TOT_IMPORTO]) " & _
              " VALUES (" & _
              "'" & DATA_RIF & "', " & _
              "'" & SPORT & "', " & _
              "'" & SEGM & "', " & _
              "'" & C_OPER & "', " & _
              "'" & MS & "'" & _
              "'" & MERC & "', " & _
              "'" & TOT_OP & "', " & _
              "'" & TOT_PZ & "'" & _
              "'" & TOT_IMP & "'" & _
              ")"
                      CN1.Execute (SQL)
      
    • in reply to: speed to write in access database… #1186768

      If you’re adding a single record, you won’t notice any difference.
      A SQL statement with INSERT INTO can add many records at once, so if you need to add multiple records, executing a SQL statement will be faster.

      ok i use INSRET INTO….

    • in reply to: GROUP BY #1186578

      CopyFromRecordset only works in an open workbook.

      ok….

    • in reply to: GROUP BY #1186570

      Excel VBA has a method CopyFromRecordset. It works as follows:

      1. Open a DAO or ADO recordset, say RST.

      2/ Use

      Range(“A2”).CopyFromRecordset RST

      See the Excel VBA help or CopyFromRecordset Method.

      yes, ok.
      But the workbook is into a dir of server and i dont want to open it, is possible?

    • in reply to: GROUP BY #1186564

      Try

      SQL = “SELECT AGENZIA_4, Count(AGENZIA_CENTRO), Count(ZONA), Count(MERCATO_DISTRIB), Count(AREA_TERRIT) FROM ” & T_TABELLE & ” WHERE TIPO_UO_1=’21’ AND DENDVAL= ‘” & Format(DATA, “yyyy/mm/dd”) & “‘ AND MERCATO_PTF=’F’ AND NOT ZONA=’N_C’ GROUP BY AGENZIA_4”

      WORK fine !

      About that…
      Admit have a workbook in \serverdirwbook.xls and a sheet named TEST.
      How to copy the entire recordset from A2 in “one shot only”, possible?
      I have see in forum existis a copyrecordsetfrom command is that?

    Viewing 15 replies - 31 through 45 (of 2,735 total)