Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2003
    Location
    Europe
    Posts
    369

    Question Unanswered: record backup feature

    I want to copy whole records from one table to a backup table whenever the actual record is being edited and when it is created the first time.

    I am thinking about creating an empty table with the same fields, adding a separate index, changing the original autonumber field to number, and adding user name and date now fields so that the changes can be traced.

    On the form, I guess the after update property is the desired one , but how should the code be?

    Moreover, is it difficult to implement "roll-back functionality to a table in Access? (after several other changes, pick a certain record for "restore").
    Last edited by kedaniel; 01-02-04 at 21:38.

  2. #2
    Join Date
    Dec 2003
    Posts
    172
    kedaniel,

    i was preparing an answer to the subform updating parent record but it looks like the question changed. did you still want an answer on the previous question, or did you realize you wanted to ask a different question entirely?

    joeg

  3. #3
    Join Date
    Nov 2003
    Location
    Europe
    Posts
    369
    Originally posted by JoeG
    kedaniel,

    i was preparing an answer to the subform updating parent record but it looks like the question changed. did you still want an answer on the previous question, or did you realize you wanted to ask a different question entirely?

    joeg
    Hi, sorry about this mess, I think it shoulg be possible to actually refer to the me.parent as I myself used as an example of what I was looking for, will check this out now, must have overlooked that obvious one (too tired? ;-) )

    If there are any other ways, I am curious anyway.

    But I tried to delete my own posting, as it looks like I should be allowed to, but then I could not do that. I could change all the content to a new message, but then I saw that my new title was not saved, it retained the title of the original posting. So I should have left it and commented on it instead. Sorry about this.

  4. #4
    Join Date
    Nov 2003
    Location
    Europe
    Posts
    369

    can a moderator please remove this thread

    - so that not more people waste their time and get confused from my mess?

    My backup question is posted in a new thread with its own title

    Wish you all a structured new year, hope I can contribute... ;-)

    kedaniel

  5. #5
    Join Date
    Dec 2003
    Posts
    172
    No problem - I found out the same thing yesterday with a message I posted - I tried editing the title and icons of a message and it didn't work for me either (at least last night).

    I'll take a look at your new message. Thanks for the response.

    Joe G

  6. #6
    Join Date
    Nov 2003
    Location
    Europe
    Posts
    369
    small question:

    Can the control source of an unbound text box be set to directly/continously reflect the value of a private variable? If so, where/how?

    I will use the control on the subform to update a value which is referenced/used in calculations in other subforms within the same main form (using a tab control). As a manual/visual control, I want that value displayed on top of the main form at all times so tha person can see that the value being used is the current/correct one (hence, need/do not need a new update - this is a currency exchange rate that should be updated at least once per day, perhaps more often).

  7. #7
    Join Date
    Dec 2003
    Posts
    172
    kedaniel

    yes. one thing i frequently do is in the form load event i will set certain unbound controls to a value.

    for example, i might have a form called search, and i want to always have certain checkboxes set a to predefined value when the form opens. at different times during the session, i might update these values based on what the user is doing.

    one popular use of setting values on a form while it's open is to set the form caption. for example, you could set the form caption of a customer editing form to "You are currently editing: John Smith's record".

    some food for thought.

    back to variables and unbound controls...

    if you use a public variable (which you store in a module) then you can write values to that variable and it will retain this value throughout the session until you close Access.

    btw: there are a lot of alternatives to public variables such as writing and retrieving values to/from a table, or using classes or type structures but the public variable is easy to implement.

    take a look at the attached example.

    IN THE DEMO FORM:

    Option Compare Database
    Option Explicit

    Private Sub Form_Current()
    Me.txtCurrencyValue = curCurrencyValue
    End Sub

    Private Sub cmdSetCurrencyValue_Click()

    'to demo how a public variable works
    'i generated a random number from 1 to 6
    'then i put the value into curCurrencyValue
    '(the public variable i used for this example)
    'then I tell Access to set this to the value of an
    'unbound text box, txtCurrencyValue

    'in real-life use you would set the currency
    'value from wherever you plan to get the latest
    'currency but I wanted to demonstrate how the
    'variable can store a value that remains in RAM
    'until you change it (or close the application)

    Dim MyValue
    Randomize
    curCurrencyValue = Int((6 * Rnd) + 1)

    Me.txtCurrencyValue = curCurrencyValue

    End Sub


    IN THE MODULE:

    Option Compare Database
    Option Explicit
    Public curCurrencyValue As Currency'this is the public variable

    one last comment. as an alternative you can, instead of a control source, use an unbound control and use a calculating field in place of the source such as:

    in the control txtCurrencyValue
    set the source to:
    =mycalculation()
    which can be another control, a series of added controls with some math equations, or a public function that you wrote in VBA.

    fun stuff, eh?

    joeg
    Attached Files Attached Files
    Last edited by JoeG; 01-03-04 at 13:18.

Posting Permissions

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