Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2007
    Posts
    20

    Unanswered: Displaying blank record for subform

    I have the following setup in my database:

    frmSTUDENTS
    Includes a HEADER section with a drop down list box that retrieves a student's record when selected.

    A Tab Control that houses two different subforms:

    - frmSUBJECTCOMMENTS
    A standard subform that is linked via StudentID to frmSTUDENTS.

    - frmCONTRIBUTIONS
    A standard subform that is linked via StudentID to frmSTUDENTS.

    What I need is this:

    (a) A way to ensure that each time frmSTUDENTS is opened, a blank record is always displayed. We want to minimise the possibility that teachers will 'accidentally' enter data for wrong student, and force them to search for their student.

    (b) A way to ensure that when a student is selected from the drop down list in the header section, the subform that is linked to frmSTUDENTS will again display a blank record.

    (c) The third thing is maybe a little trickier? I have a SAVE CHANGES button at the end of the form (I know it's not necessary, but otherwise people will ask how to save it all!) I need some kind of a procedure where, once this button is clicked, it actually prevents the teacher from overwriting data in that record unless they specifically choose to overwrite it. This is again intended as a safeguard against teachers who might unwittingly forget to locate their next student to repeat the process.

    Thanks for any help you are able to offer me!

  2. #2
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,424
    Provided Answers: 8
    How have you setup the Master / child link in the form

    What I would do
    (a) open screen frist asking the user What student they want to look @ then open the frmSTUDENTS form
    and @ the top of the screen have a find student combo box something surname first name listing

    (b)


    (c) Set up a Flag in form
    CanEdit = True / False when form to open the Canedit = True but once the they have save it make the Canedit = False
    But you will have to write some code so that when a data is over type in a feild it check the the status of the CanEdit
    hope this help

    See clear as mud


    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.

  3. #3
    Join Date
    Oct 2007
    Posts
    20
    Hi there

    Thanks for your reply!

    Object name: sfmSubjectComments
    Source Object: frmSubjectComments (whose source is qrySubjectComments)
    Link Child Fields: StudentID
    Link Master Fields: StudentID

    When you suggest having a screen that asks what student they want to look at, do you mean in a switchboard format? How would this be best set up? (I can't remember how to set up a switchboard, and what objects/code would be required?)

    I think it would be a royal pain to do this now(!) but I wondered whether there's likely to be a simple(?) way that allows me to select the Teacher of that student from the dropdown list, and then have a combo box below (instead of the existing Dropdown box for a list of ALL subjects taught at the school) that lists only the subjects prescribed as being taught by that teacher? (I've attached a screenshot of my relationships diagram and form interface, in case that helps at all)

    For (c) do you know what kind of code would be needed to check the status of the Canedit?

    Thanks again for your help.
    Attached Thumbnails Attached Thumbnails RelationshipDiagram.bmp   FormDiagram.bmp  

  4. #4
    Join Date
    Oct 2002
    Location
    Baghdad, Iraq
    Posts
    697
    Quote Originally Posted by kazzabelle
    (a) A way to ensure that each time frmSTUDENTS is opened, a blank record is always displayed. We want to minimise the possibility that teachers will 'accidentally' enter data for wrong student, and force them to search for their student.
    Don't have access in front of me, but... create a button. The little wizard will pop up, ask for the "move last" command.

    That creates the code for move last... now what you want is for that code to fire when the form is loaded rather than when the button is click. You just need to change the name of the subroutine the wizard generates so it says "Sub Form_Onload()" instead of "Sub Command1_OnClick". It's that easy...

    (Then you can delete the button.)

    (b) A way to ensure that when a student is selected from the drop down list in the header section, the subform that is linked to frmSTUDENTS will again display a blank record.
    So the dropdown changes the current record? And, this wasn't clear, but I take it that frmCOMMENTS and frmCONTRIBUTIONS show multiple records per StudentId?

    If that's the case, then you just need to pull up the code you wrote for the dropdown. The code the wizard generated probably uses DoCmd or something like that... unfortunately, I think it only works on the current form. But you can use Me.SubformName.Form.Setfocus to make it the current form, then use the DoCmd code immediately afterwards. You should then set the focus back to your main form with Me.Setfocus.

    (c) The third thing is maybe a little trickier? I have a SAVE CHANGES button at the end of the form (I know it's not necessary, but otherwise people will ask how to save it all!) I need some kind of a procedure where, once this button is clicked, it actually prevents the teacher from overwriting data in that record unless they specifically choose to overwrite it. This is again intended as a safeguard against teachers who might unwittingly forget to locate their next student to repeat the process.
    So you want to check whether or not the current record is the "new" record and if not pops up a message asking them if they want to overwrite the existing record? Also, you'd probably want to trap moving away from the record or closing the form.

    Checking whether you're on the new record isn't hard... I think you need to get into the recordset but I'll have to wait until I can pull up Access tomorrow.

    Trapping moving away from the record is easy too, you just have to add some event handlers to the form object. In fact, the button would just tell the form to update itself and trigger the event handler.

Posting Permissions

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