Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
| Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old November 2nd, 2004, 03:59 PM
Authorized User
 
Join Date: Apr 2004
Location: Montreal, Quebec, Canada.
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to lguzman
Default Creating a log file from actions taken in a form

I have created a form where users select a start range, end range and a adjusting value. They would then click on a "GO" button, an a update query will modify the value of the selected range by the adjusting value. I would like to keep track of the changes made by the users by appending the starting range, end range, adjustment value and date in a log file.

I have come up with the following code but I keep getting a "No current record." error.

    Dim wrkDefault As Workspace
    Dim dbs As Database
    Dim rst As Recordset
    Set wrkDefault = DBEngine.Workspaces(0)
    Set dbs = CurrentDb
    Set rst = dbs.OpenRecordset("PrinterNumberConversionLog")
    wrkDefault.BeginTrans
    With rst
         .AddNew
         !LogAdjustedDate = Date
         !LogStartingRange = [Forms]![AAA-4to7DigitForm]![StartRange]
         !LogEndingRange = [Forms]![AAA-4to7DigitForm]![EndRange]
         !LogAdjustmentBy = [Forms]![AAA-4to7DigitForm]![AdjustBy]
         .Update
         .MoveNext
    End With
    wrkDefault.CommitTrans
    dbs.Close

Thanks.



[LGuzman]
__________________
[LGuzman]
  #2 (permalink)  
Old November 2nd, 2004, 04:19 PM
Authorized User
 
Join Date: Oct 2004
Location: Austin, TX, USA.
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What is the purpose of the .MoveNext? Because you just added a record, you're on the "last" one in the recordset, so a MoveNext will get you No Current Record.

And by the way, if this code is running in the form named [AAA-4to7DigitForm], you can reference the controls using Me:

  !LogStartingRange = Me.StartRange


John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
  #3 (permalink)  
Old November 3rd, 2004, 10:58 AM
Authorized User
 
Join Date: Apr 2004
Location: Montreal, Quebec, Canada.
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to lguzman
Default

Thanks for your help.



[LGuzman]


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't get Log to write the Log.txt file jnbutler BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6 3 July 31st, 2007 04:04 AM
Creating an excel file and showing on the form dotnetprogrammer C# 0 May 3rd, 2005 07:36 AM
Log file tsimsha Classic ASP Databases 1 April 30th, 2005 04:27 AM
problem for creating the separate log file for con goel_man Apache Tomcat 0 December 19th, 2004 11:48 AM
Creating a log file for multiple users patwadd Classic ASP Basics 19 June 24th, 2004 08:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.