Results 1 to 7 of 7

Thread: Dynaset Question?? Need Help badly

  1. #1
    Guest
    Hi guys,
    I have a Dynaset called jkSS. What I need to do I write the contents of the Dynaset to a log file. I am using the open and print to write it to the log file but I really don't have a clue how to get the contents of the table to the log file.
    Please help
    Stephen.

  2. #2
    Lively Member
    Join Date
    Jan 1999
    Location
    Lincolnshire, UK
    Posts
    111
    Try this bit of code

    Dim Tbl as tabledef
    Dim Fld as field
    Dim RS as recordset
    Dim LogFile as string
    Dim FileID as long
    dim PrintString as string

    'open the recordset
    set rs=db.openrecordset("Whatever",dbopendynaset)
    'make sure that there is some data to log
    if rs.eof then
    msgbox "There is no Data in the Recordset!"
    else
    'set the fileid var to the next free file number
    fileid=freefile
    'set the log file location to the same as the app
    logfile=app.path
    'make sure that there is a \ on the end of the string as
    'sometimes the app.path has one and some times it doesn't
    '(ie if you are running from the root of a drive it does,
    'else it doesn't)
    if right(logfile,1)<>"\" then
    logfile=logfile & "\"
    end if
    'add the file name to the path
    logfile=logfile & "MyFirstLog.Log"
    'open the file
    open logfile for output as fileid
    'loop through the fields in the recordset
    for each fld in rs.fields
    printstring=printstring & vbtab & vbtab & fld.name
    next
    print #fileid,printstring
    do while not rs.eof
    printstring=""
    for each fld in rs.fields
    printstring=printstring & vbtab & vbtab & rs(fld.name)
    next
    print #fileid,printstring
    rs.movenext
    loop
    close #fileid

    'now view the file
    call shell("notepad.exe " & logfile,vbnormalfocus)



    Hope this helps, if not, email me ([email protected])

    Cheers

    Chris

  3. #3
    Guest
    Thanks a lot for the reply. I'll test it out now.
    Kind Regards
    Stephen

  4. #4
    Addicted Member
    Join Date
    Aug 2000
    Location
    Ireland
    Posts
    224
    Maybe someone can help me with my question also.

    I also have a Dynaset that I need to extract the values from

    Code:
    User![Expiry Date] = Format$(Date + PasswordExpiry, "dd/mm/yyyy")
    User is the Dynaset. How do I extract the values of the fields that follow.

  5. #5
    Lively Member
    Join Date
    Jan 1999
    Location
    Lincolnshire, UK
    Posts
    111
    kanejone

    If this is for an expiry date of a password from the current date, the best bet is

    user![Expiry Date]=format(dateadd("d",NumberOfDays,now),"mm/dd/yyyy")

    Where number of days is how many days until expiry (of course). The reason this is formatted mm/dd instead of dd/mm is that databases have a tenancy to be American rather than British (I've no idea where you live), but this is something for us Brits to watch out for. If you want to add something other that a day, try looking at the help for dateadd. If this is something else, email me.

    Cheers

    Chris

    [email protected]

  6. #6
    Addicted Member
    Join Date
    Aug 2000
    Location
    Ireland
    Posts
    224
    Hi Chris
    Thanks for the reply. I am actually here in Dublin. See the problem that I have is that I have a program that works fine here, but shipped it over to India and the Change Password routine won't work at all on it. I logged it to a log file and found out that the program wouldn't pass this part. So what I wanted to do was write out the values of the User(which is a dynaset) and try to figure out what variables are having trouble being passed. I appreciate any advice that you may be able to offer.

    Thanks a lot for you time,
    Take Care
    JK

  7. #7
    Lively Member
    Join Date
    Jan 1999
    Location
    Lincolnshire, UK
    Posts
    111
    My previous post should work for your problem as well, but one thing I think might be worth checking is the date and time format on the machines in India. Sounds stupid, but I've had no end of problems in UK programming because a machine has only 2 y's instead of 4 or the time is hh:mm:ss instead of hh:mm. Something worth looking at

    Cheers

    Chris

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width