?
Solved

creating data file one per day!!!

Posted on 2003-03-31
7
Medium Priority
?
143 Views
Last Modified: 2010-05-01
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
Comment
Question by:anandxx
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 

Expert Comment

by:hkoldoldguy
ID: 8244168
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
 

Expert Comment

by:Andre998
ID: 8244261
'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
 
LVL 2

Expert Comment

by:AKbor75
ID: 8244840
anandxx, please don't use all caps !!!
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:anandxx
ID: 8258979
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
 

Expert Comment

by:modulo
ID: 8390332
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
 

Accepted Solution

by:
modulo earned 0 total points
ID: 8404542
Saving this Q as a PAQ and refunding the 200 points to the questionner

modulo

Community Support Moderator
Experts Exchange
0
 

Expert Comment

by:Andre998
ID: 8532773
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month12 days, 10 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question