Consulting

Results 1 to 7 of 7

Thread: tab control, sub form acCmdSaveRecord prvious control problem

  1. #1
    VBAX Mentor Movian's Avatar
    Joined
    Aug 2008
    Location
    NC, USA
    Posts
    399

    tab control, sub form acCmdSaveRecord prvious control problem

    as you probably guessed from the title this issue is a little complex so i will lay a little background.

    I have a main form that has a sub form section. Using buttons on the main form you can change which form is currently being used as the subform. Each subform has a tab control.

    so i have a client who INSISTS on being able to look at the same record on two machines.... don't ask i just have to make it work. My solution was to run

    [vba]DoCmd.RunCommand acCmdRefresh
    DoCmd.RunCommand acCmdSaveRecord[/vba]
    for both the subform and the main form (for some reason if i did it just the once it would only save the form that currently had focus) so i ended up producing the following code
    [vba]If myrs.Fields("AutoSave") = True Then

    DoCmd.RunCommand acCmdRefresh
    DoCmd.RunCommand acCmdSaveRecord

    Me.MedicalID.SetFocus
    DoCmd.RunCommand acCmdRefresh
    DoCmd.RunCommand acCmdSaveRecord
    PreviousControl.SetFocus

    End If[/vba]
    Now my issue lies in the issue that if a control on the main form is selected, the focus returns to that control through the previous control function. However if a control on the sub form has the focus the code does not return focus to the selected control but instead keeps focus on the field MedicalID on the main form. This can cause issues as the saving code is on the ontimer event meaning if someone is typing somthing and they get the focus on the medical id they start overiting the medical ID. i have looked through the diffrent options for the screen.previouscontrol etc but i can't even get the form name to manually set the forms("fmMain").controls("fsubmodule").controls(controlname).setfocus value myself as i can only ever return the form name of frmmain or the tab name instead of the subform name....

    any help is apriciated.
    "From the ashes of disaster grow the roses of success" - Chitty chitty bang bang

    "I fear not the man who has 10,000 kicks practiced once. I fear the man who has 1 kick practiced 10,000 times" - Bruce Lee

  2. #2
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    Have you tried using the me.Parent.Subform.control syntax?
    I am not sure that I understand why you are doing this though, what is the problem of displaying the same record on 2 different machines. You can set the Table's Record Locking properties to allow more than 1 person to view the data, but only 1 to actually Edit it. The second "Viewer" is notified when the Record is free to edit on their Computer.

  3. #3
    VBAX Mentor Movian's Avatar
    Joined
    Aug 2008
    Location
    NC, USA
    Posts
    399
    The problem is that they have two machines, one is a tablet and another is a desktop. They Create a NEW record on the tablet and enter data. Then without moving or logging of they move to the desktop, but when they search for the patient record it claims it is not there. Also could you point me in the direction of those record locking options? i would like to look over them and see if i can use them in the system.
    "From the ashes of disaster grow the roses of success" - Chitty chitty bang bang

    "I fear not the man who has 10,000 kicks practiced once. I fear the man who has 1 kick practiced 10,000 times" - Bruce Lee

  4. #4
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    Have you forced a Record Save on the tablet machine. Quite often the record is written to the table but not "displayed"/"released", sometimes not until the form is closed or you move to a new record.
    See the Main Menu>Tools>Options>Advanced for Record locking.

  5. #5
    VBAX Mentor Movian's Avatar
    Joined
    Aug 2008
    Location
    NC, USA
    Posts
    399
    That was essnetially what i was trying to do. So that the information would be displayed on the second machine. However The record locking will not work in this case because they leave the tablet on the patients record then want to edit the same record on the other machine. So the code i have is trying to force the save and refresh so any new records are shown. My other clients should be happy with the record locking. But i still need to find out how to force the save on both the main form and the sub form and keep focus on the current control...
    "From the ashes of disaster grow the roses of success" - Chitty chitty bang bang

    "I fear not the man who has 10,000 kicks practiced once. I fear the man who has 1 kick practiced 10,000 times" - Bruce Lee

  6. #6
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    You could store the Record (s)in a Public/Global Variable, close the form and then re-open it and move to that record.
    Or better still update the Table with a VBA Recordset, that is probaly not controlled by Record locking.

  7. #7
    VBAX Master CreganTur's Avatar
    Joined
    Jan 2008
    Location
    Greensboro, NC
    Posts
    1,676
    Location
    When you work with DAO recordsets, one of the parameters you can specify the type of recordset to open. The dbOpenTable type is basically a mirror of your table, and it will reflect any changes recently made to your table. If that doesn't meet your needs, then look into dbOpenDynamic.

    HTH
    -Randy Shea
    I'm a programmer, but I'm also pro-grammar!
    If your issue is resolved, please use Thread Tools to mark your thread as Solved!

    PODA (Professional Office Developers Association) | Certifiable | MOS: Access 2003


Posting Permissions

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