Updating Mainform(SubForm1 from (SubForm2) )

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Weise
    New Member
    • Jun 2010
    • 11

    Updating Mainform(SubForm1 from (SubForm2) )

    Your Question was:

    Hi there, I have a small Problem which I cannot resolve and am wondering if you could help me. Basically I have 3 Forms Names ClientForm/VehicleForm & JobForm.the MainForm is ClientForm which has the VehicleForm embedded as a SubForm of ClientForm.the embeded VehicleForm also has an Embedded form called JobForm. All forms are updated in order from Left to Right ClientForm>Vehi cleForm>JobForm .

    See Attached image for Clearer image.

    I can access the controls on the VehicleForm from within the JobForm using: Forms!VehicleFo rm!VehicleContr ol no problems however When trying to Access the VehicleForm from the JobForm whilst embedded into the ClientForm the Following does NOT work:
    Forms!ClientFor m!VehicleForm!V ehicleControl , likewise as advised at the below site:
    MVPS.ORG

    I have tried:
    Forms!Mainform! Subform1.Form!C ontrolName which Proceeds to give me an Error which states "cannot find FIELD SubForm1" ?

    Hopefully you could help me with this .

    Kind Regards

    Weise

  • TheSmileyCoder
    Recognized Expert Moderator Top Contributor
    • Dec 2009
    • 2322

    #2
    Im not exactly sure why it isn't working. Your sure the CONTROL containing your subform is named SubForm1?

    A form has a name regardless of whether its used as a form or a subform, thats the name you see in the Database explorer window (Don't really know if its called such). When you embed a form into another form, the subform is contained in a control, which can be named differently from the name of the form. Make sure your using the name of the control, not the name of the form.
    Another approach that can be used:
    Code:
    Me.Parent.Form.VehicleWarrantExp=Me.NextWarrentDate
    Or:
    Code:
    Docmd.Setwarnings False
      Docmd.RunSQL "UPDATE tbl_Vehicles " & _
                   "SET VehicleWarrantExp=#" & Me.NextWarrentDate & "# " & _
                   " WHERE KEY_Vehicle=" & Me.VehicleID"
    Docmd.SetWarnings True
    Something I can't help but notice since I am looking at it, is why do you have the VehicleID as a dropdown in your Job-subform? The Job-Subform is a subform of teh Vehicle, and as such should be related directly to the vehicle, through the subform binding.

    Comment

    • Weise
      New Member
      • Jun 2010
      • 11

      #3
      Hello SmileyOne :D, Thank you for your help on this one I Greatly Appreciate it.
      and for your efforts I do not mind sharing this Database with this forum to help others in the same predicament as myself.

      if you open the database and run the VehicleForm then update the NewWarrantDate field the NextwarrantDue field will be automatically updated afterwhich clicking on the [update] button transfers the NewWarrantDate over to the vehicle Form updating this information. However it does not work at all When loaded through the ClientForm as you will see.

      Regarding the VehicleID you are correct this does not need to be a combobox and will be changed to a TBox.

      thank you for your time and efforts in assisting me.

      much appreciated.

      Weise.
      Attached Files
      Last edited by Weise; Jun 15 '10, 08:39 PM. Reason: again trying to stick to the point

      Comment

      • TheSmileyCoder
        Recognized Expert Moderator Top Contributor
        • Dec 2009
        • 2322

        #4
        Looking at your database, I can see that the control containing the vehicle form is named vehicleTable, just like I suspected and took the time to explain in my first post.

        Changed the line of code to:
        Code:
        Forms!ClientForm!VehicleTable.Form!VehicleWarrantExp = DateAdd("m", [WarrantTerm], [NewWarrantDate])
        and it worked.

        If your looking for help, you should at least take the time to read the replies people make.

        Comment

        • Weise
          New Member
          • Jun 2010
          • 11

          #5
          Sorry M8 , was late last night and I had read your post but was adamant that I had the right Control :| Thank you.
          Last edited by Weise; Jun 15 '10, 08:35 PM. Reason: will try to stick to the point

          Comment

          Working...