Results 1 to 2 of 2

Thread: VBA Programming

  1. #1
    Join Date
    Oct 2003

    Thumbs up Unanswered: VBA Programming

    Hello all, im a new member here, hope you all can help.

    Creating a dbase in ms access 2000 at the mo, and have come up with a problem. Am using unbound forms and have hardcoded the text boxes so that they put the data entered into the relevant fields in the relevant tables no problem. But because the forms are unbound I need to create a button to save the details in these tables.

    I can do this by itself fine, but on the same form I want a button that i press which displays another form that requiers the user to input some address details. Again can do this fine.

    The problem i have is that the user now has 2 buttons to press and i only want the user to have to press one button. Tried to create one button that firstly saves the details and secondly brings up the address input form. I have done this ok, but in some cases more than one lot of address details needs to be entered against the details on the main form, but every time i press the 'new address' button (which now firstly saves the data on the main form, and secondly brings up the input form) the details entered in the main form are re-saved, creating duplicate records. Any ideas how to write some code for the on click event that checks to see if details on the main form has been saved once, and if it has, then it skips that saving step and just brings up the address input form.

    Sorry for the long explination, im new at this and dont know how much infor u people need to be albe to help.

    look forward to your reply, and thank in advance!!!

  2. #2
    Join Date
    Jul 2003
    Since the "On Dirty" event only applies to bound forms, you'll have to create your own version of the "Dirty" event. It's kinda cumbersome, but it works.

    Create a module level variable:

    Dim bolDirty as boolean

    In the form's On current event:
    bolDirty = false

    For each control that contains data that will be saved,
    in the AfterUpdate event:
    bolDirty = True

    In the last line of code for your Save button:
    bolDirty = false

    Then in the code for the New Address, you can check
    the status of bolDirty:
    If bolDirty = true then
    'save the record
    'don't save the record
    End if

    Hope that works for you.
    Inspiration Through Fermentation

Posting Permissions

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