Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 152
  • Last Modified:

creating data file one per day!!!

OK IM USING VB TO LOG
INFORMATION FORM SERIAL PORT EVERY 15 MINUTES.

THIS INFORMATION WILL BE USED TO CREATE A GRAPH LATER.

I NEED TO SAVE THE INFORMATION 15 MINUTES ONTO

( RECOMMEND A FORMAT) A FILE - PROBLEM IS I NEED TO

SAVE IT TO A FILE ( ONE PER DAY) VIZ

FOR 13 MARCH -  ONE FILE ( CONTANING 15 MIN SLOT DATA FOR 13 MARCH)

SAME FOR 14 MARCH.. ETC.


I USED MDB AND MADE A DATA SET TO TAKE DATA IN.

DONT KNOW HOW TO CREATE A FILE FROM WITH IN VB, OR DO YOU
RECOMMEND OTHER FILE TYPES INSTED OF MDB.


ASHOK
0
anandxx
Asked:
anandxx
1 Solution
 
hkoldoldguyCommented:
Dim fso
Dim FilePath As String
Dim FileInput
Dim dtFileDate As String
Dim sTemp As String
Dim iDay As String
   
Set fso = CreateObject("Scripting.FileSystemObject")
FilePath = App.Path
If Right(FilePath, 1) <> "\" Then
   FilePath = FilePath & "\"
End If
   
If Not fso.FileExists(FilePath & format(now,"yyyymmdd")) Then
   Set log = fso.CreateTextFile(FilePath & format(now,"yyyymmdd")) True)
   log.Write " "
   log.Close
End If
0
 
Andre998Commented:
'This should do for adding info to a logfile
'If you want to add it to a mdf where mdf has to
'be an Access database then you have to do a
'lot more....
Public Sub AppLog(strFile as String, strMsg As String)
'''''''''''''''''''
' INPUT: strFile = complete filename without extention
'        strMsg = logmessage
' OUTPUT: Applog("d:\logs\test","show me")
'         adds 01 april 2003 11:08:08 : show me
'         to logfile d:\logs\test20030401.log
'''''''''''''''''''
 Dim intFree As Integer
   
 intFree = FreeFile
 Open strFile & Format(Date, "YYYYMMDD") & ".log" &_
      For Append As #intFree
 Print #intFree, Format(Now, "dd mmm yyyy hh:mm:ss") & _
       & " : " & strMsg
 Close #intFree
   
  Exit Sub
End Sub
0
 
AKbor75Commented:
anandxx, please don't use all caps !!!
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
anandxxAuthor Commented:
thanks the for the response. sorry about the capitals.


let me try and rephrase the question.

- Yes the data will have to be in a database. (mdb)
  which has fields (time) (date) (number)

- i have made an mdb file COUNT.MDB and am able to
  save into it from VB using a timer (Say 15 min
  interval).

All the above works fine.

However, since it saves to a single file, i will have
relatively huge file in a month or a year.

What im looking to do is instead of saveing to
COUNT.MDB every day, to have a file one per day

say COUNT1.MDB
    COUNT2.MDB

alternatively,  C020403.MDB
                C030403.MDB
                C040403.MDB

WHERE say 02 - date 04 month 03 year.

hope this is more clear.

Regards,

ak
0
 
moduloCommented:
Dear expert(s),

A request has been made to close this Q in CS:
http://www.experts-exchange.com/Community_Support/New_Topics/Q_20582098.html

Without a response in 72 hrs, a moderator will finalize this question by:

 - Saving this Q as a PAQ and refunding the points to the questionner

When you agree or disagree, please add a comment here.

Thank you.

modulo

Community Support Moderator
Experts Exchange
0
 
moduloCommented:
Saving this Q as a PAQ and refunding the 200 points to the questionner

modulo

Community Support Moderator
Experts Exchange
0
 
Andre998Commented:
Here I have the solution using DAO. You can also use ADOX if you want to but that's a little bit different from DAO. I hope this will help you.

P.s. sorry for the late reaction

' =======================================================
' code in form1 as an example
' form1 is a form with a command button to test the stuff
' =========================================================
Option Explicit

Public gWKS As DAO.Workspace
Public gDB As DAO.Database
Public gRS As DAO.Recordset

Private Sub Command1_Click()
  Dim strDBName As String
   
  strDBName = "c:\log" & Format(Now, "yyyymmdd") & ".mdb"
  OpenDatabase (strDBName)  
  CloseDatabase (strDBName)
   
End Sub

Private Sub OpenDatabase(strDB As String)
  Dim objFSO As Object
  Dim bExists As Boolean, strStamp As String
   
  Set objFSO = CreateObject("Scripting.FileSystemObject")
   
  ' Check if db already exists; if not, create one
  If objFSO.FileExists(strDB) Then
    bExists = True
  Else
    Set gDB = DBEngine.CreateDatabase(strDB, dbLangGeneral)
  End If  
   
  ' Create workspace and open database
  Set gWKS = CreateWorkspace("", "admin", "", dbUseJet)
  Set gDB = gWKS.OpenDatabase(strDB)
       
  ' If new database then generate table
  If bExists Then
    gDB.Execute "insert into LOGDETAILS values ('" & _
                Format(Now, "yyyymmddhhnnss") & _
                "','Database opened')"
  Else
    gDB.Execute "CREATE TABLE LOGDETAILS(" & _
                "Stamp VARCHAR(14) NOT NULL, " & _
                "Detail VARCHAR(40)  NOT NULL)"
  gDB.Execute "insert into LOGDETAILS values ('" & _
                Format(Now, "yyyymmddhhnnss") & _
                "','Database generated')"
  End If
   
  Set objFSO = Nothing

End Sub

Private Sub CloseDatabase(strDB As String)
    gDB.Close
    Set gDB = Nothing
    Set gWKS = Nothing
End Sub

'=========================================================
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now