Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Sep 2002
    Location
    East Coast(USA)
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Force data entry (Acc 2000)

    Greetings,
    I have a main form called HouseHold and a subform called Applicants. For every HouseHold there can be more than one applicant (one-to-many relation). I

  2. #2
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Leuven, Vlaanderen, Belgium
    Posts
    322
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Re: Force data entry (Acc 2000)

    Just a quick thought...
    Try to use this code in your subform control's enter event property. When a user wants to enter the subform while he's in a new record, it won't be possible. As soon as he has entered some value in a main form control, he will gain access to the subform & the warning won't show anymore:

    Private Sub subFrmCtlName_Enter()
    If Me.NewRecord Then
    MsgBox "Warning"
    ctlMain.SetFocus
    End If
    End Sub

    => subFrmCtlName = Name of the subform control on your form (NOT the name of the corresponding form object in the database window!)
    => CtlMain = the first control on your main form which should be filled with information first...

    I tried it for a second and realised you should also write some extra code to prevent the warning from occuring when the user starts a new record from within the subform (e.g. the pointer is in subform when user presses new record button). This could be done with something like:

    Private Sub Form_Current()
    if me.NewRecord then
    ctlMain.SetFocus
    end if
    End Sub

    I didn't evaluate all possible side effects (e.g. instead of focussing on that specific main form control, it should be better if the focus could remain at the current control if it's on the main form) but it might do. Though people with more experience in these matters might have some better/complementary suggestions,

    Hasse

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Force data entry (Acc 2000)

    You can also take a look at the Orders form and its subform in the Northwind sample database that comes with Access.
    In the subform, the Form_Error event procedure is used to catch the error that occurs if the user tries to enter a record in the subform before a record in the main form has been entered. a warning is issued, the new record is canceled, and the focus is set back to the main form.

  4. #4
    3 Star Lounger
    Join Date
    Jun 2002
    Location
    Nottingham, Nottinghamshire, United Kingdom
    Posts
    257
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Force data entry (Acc 2000)

    I have similar types of data entry, in one case involving 3 tables. In all my databases I use specific Add forms populated with unbound text fields to collect the data I want to store. A Save button then invokes code which adds the data to tables. I use transactions to ensure that all tables are updated at the same time.

    This approach means that I can have all the error checking I need before actually committing the data and I don't have to worry about partial saves.

Posting Permissions

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