Results 1 to 2 of 2
  1. #1
    MWhitfield is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2010
    Posts
    4

    Very easy question - preserving variables between sessions

    Hi folks. Been using Access for a couple months now, and trying to get into writing the VBA myself. Very new at this (like 2 hours new), so this is probably absurdly basic, but bear with me.



    So basically what I want to do is this: I have two tables, Inventory and Mixtures. Mixtures is a linked table to another database, and there's a one-to-many relationship from Inventory to Mixtures. What I want is for the database, on load, to iterate through each new entry of Mixtures, fetch a particular value from each row, and subtract that value from the corresponding entry in Inventory.

    Now, I only want this to be done for NEW entries to Mixtures, so basically I want to store somewhere the highest primary key in Mixtures from the last time the code was run. How do I do this? Will the variable in the code automatically be preserved from session to session? If so, how do I set an initial value for the variable only the first time the code is run?

  2. #2
    ConneXionLost's Avatar
    ConneXionLost is offline Simulacrum
    Windows XP Access 2003
    Join Date
    Jan 2010
    Location
    Victoria, Canada
    Posts
    291
    The easiest way is to create a small table for this purpose. You can either overwrite the existing value, or timestamp the entries and keep some history.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Easy newbie question
    By pontuse in forum Access
    Replies: 4
    Last Post: 11-08-2009, 08:02 AM
  2. HELP NOOB! Easy question
    By SigmaBlu in forum Queries
    Replies: 1
    Last Post: 10-10-2009, 11:23 AM
  3. Easy question...so why can't I figure it out?
    By bdrago527 in forum Access
    Replies: 1
    Last Post: 10-02-2008, 02:40 PM
  4. easy checkbox question
    By nelsok in forum Forms
    Replies: 1
    Last Post: 06-09-2006, 05:46 PM
  5. sql in vb variables
    By emilylu3 in forum Programming
    Replies: 3
    Last Post: 03-04-2006, 01:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums