-
WSsal21
AskWoody LoungerTry
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?
-
WSsal21
AskWoody LoungerYou’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
-
WSsal21
AskWoody LoungerYou 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 . … -
WSsal21
AskWoody LoungerPlease 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″
-
WSsal21
AskWoody LoungerSee 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? -
WSsal21
AskWoody LoungerYou could do something like this:
Dim cnn As ADODB.Connection
Dim rst As New ADODB.Recordset
Dim strSQL As String
Dim lngCount As LongSet 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 = NothingEXCELLENT!
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?
-
WSsal21
AskWoody LoungerYou 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…. -
WSsal21
AskWoody LoungerYes. 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 -
WSsal21
AskWoody LoungerYou 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. -
WSsal21
AskWoody LoungerYou 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? -
WSsal21
AskWoody LoungerIf 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)
-
WSsal21
AskWoody LoungerIf 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….
-
WSsal21
AskWoody Lounger -
WSsal21
AskWoody LoungerExcel 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? -
WSsal21
AskWoody LoungerTry
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?
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Marriage Counseling – Manages To Do It Save Our Marriage? (Awaiting moderation)
by
lynwoodspellman
3 hours, 29 minutes ago -
Where’s the cache today?
by
Up2you2
3 hours, 22 minutes ago -
Ascension says recent data breach affects over 430,000 patients
by
Nibbled To Death By Ducks
10 hours, 28 minutes ago -
Nintendo Switch 2 has a remote killing switch
by
Alex5723
10 hours, 48 minutes ago -
Blocking Search (on task bar) from going to web
by
HenryW
4 hours, 3 minutes ago -
Windows 10: Microsoft 365 Apps will be supported up to Oct. 10 2028
by
Alex5723
20 hours, 36 minutes ago -
Add or Remove “Ask Copilot” Context Menu in Windows 11 and 10
by
Alex5723
20 hours, 43 minutes ago -
regarding april update and may update
by
heybengbeng
22 hours, 12 minutes ago -
MS Passkey
by
pmruzicka
8 minutes ago -
Can’t make Opera my default browser
by
bmeacham
1 day, 5 hours ago -
*Some settings are managed by your organization
by
rlowe44
16 hours, 35 minutes ago -
Formatting of “Forward”ed e-mails
by
Scott Mills
1 day, 4 hours ago -
SmartSwitch PC Updates will only be supported through the MS Store Going Forward
by
PL1
2 days ago -
CISA warns of hackers targeting critical oil infrastructure
by
Nibbled To Death By Ducks
2 days, 9 hours ago -
AI slop
by
Susan Bradley
3 hours, 24 minutes ago -
Chrome : Using AI with Enhanced Protection mode
by
Alex5723
2 days, 10 hours ago -
Two blank icons
by
CR2
22 hours, 29 minutes ago -
Documents, Pictures, Desktop on OneDrive in Windows 11
by
ThePhoenix
2 days, 19 hours ago -
End of 10
by
Alex5723
2 days, 22 hours ago -
Single account cannot access printer’s automatic duplex functionality
by
Bruce
1 day, 20 hours ago -
test post
by
gtd12345
3 days, 4 hours ago -
Privacy and the Real ID
by
Susan Bradley
2 days, 18 hours ago -
MS-DEFCON 2: Deferring that upgrade
by
Susan Bradley
20 hours, 49 minutes ago -
Cant log on to oldergeeks.Com
by
WSJonharnew
3 days, 8 hours ago -
Upgrading from Win 10
by
WSjcgc50
1 day, 20 hours ago -
USB webcam / microphone missing after KB5050009 update
by
WSlloydkuhnle
1 day, 23 hours ago -
TeleMessage, a modified Signal clone used by US government has been hacked
by
Alex5723
4 days ago -
The story of Windows Longhorn
by
Cybertooth
3 days, 12 hours ago -
Red x next to folder on OneDrive iPadOS
by
dmt_3904
4 days, 2 hours ago -
Are manuals extinct?
by
Susan Bradley
1 day, 2 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.