Create Schema.ini (1 Viewer)

Kronosds

New member
Local time
Yesterday, 19:33
Joined
Jun 11, 2017
Messages
9
Hi there,

I have a new question.

Is there any way to dynamically create a Schema.ini file?

Problem is that I have a function that requires a Schema.ini file, and this file always has to be in the same directory where the current database is.
But the user can accidentally delete this file, so I want to create the dynamic Schema.ini every time the user clicks a button the file is created.

Structure my Schema.ini

[WebUsref.csv]
ColNameHeader=False
CharacterSet=ANSI
Format=Delimited(,)
DecimalSymbol=.
MaxScanRows=0

Regards

Kronossds
 

isladogs

MVP / VIP
Local time
Today, 03:33
Joined
Jan 14, 2017
Messages
18,246
Yes - its a standard text file so use 'logstream' code

Code:
Sub WriteToFile(strLogFile As String, strLogEntry As String)
    On Error Resume Next
    
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set logStream = objFSO.OpenTextFile(strLogFile, ForAppending, True) 'Open log file
    
    logStream.WriteLine strLogEntry
    
    logStream.Close
End Sub

So in your case strLogFile is the full file path of schema.ini
Add the text one line at a time in quote marks starting with:

strLogEntry="[WebUsref.csv]"
 

Kronosds

New member
Local time
Yesterday, 19:33
Joined
Jun 11, 2017
Messages
9
Hello ridders,

I implemented this code and it works for me, is there any advantage or disadvantage in doing the schema.ini with this code?

Code:
Private Sub CmdUpDate_Click()
Dim Path As String
Path = CurrentProject.Path & "\Schema.ini"
'Open "C:\SharePlant\Schema.ini" For Output As #1
Open Path For Output As #1
        Print #1, "[[FONT="Calibri"]WebUsref.csv[/FONT]]"
        Print #1, "ColNameHeader=False"
        Print #1, "CharacterSet=ANSI"
        Print #1, "Format=Delimited(,)"
        Print #1, "DecimalSymbol=."
        Print #1, "MaxScanRows=0"
        Close #1
   
End Sub
 

isladogs

MVP / VIP
Local time
Today, 03:33
Joined
Jan 14, 2017
Messages
18,246
There's always several ways of doing anything in Access

I've also used the method you have listed.
If it works for you then I'd stay with it.

For such a short file as your schema.ini, I doubt you'd notice any time difference with either method
 

Kronosds

New member
Local time
Yesterday, 19:33
Joined
Jun 11, 2017
Messages
9
Thank you, then I will stay with this method.

I have a question more, how do I close the thread?

Kronosds
 

isladogs

MVP / VIP
Local time
Today, 03:33
Joined
Jan 14, 2017
Messages
18,246
You mark it as SOLVED

Click on Thread Tools drop down in the blue bar above the posts then select that mark as solved option
 

Users who are viewing this thread

Top Bottom