Create Schema.ini

Kronosds

New member
Local time
Today, 09:57
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
 
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]"
 
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
 
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
 
Thank you, then I will stay with this method.

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

Kronosds
 
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

Back
Top Bottom