Have a different subforms load depending on cell in a record of theparent form

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rob

    Have a different subforms load depending on cell in a record of theparent form

    I am putting together a small Access 2003 DB to record details of our
    motorvehicles. (this is more to teach myself some basics with Access)

    The main form is holding data that is common to most vehicles. Eg.
    Registration date, expiry, VIN/Chassis, Make, Model, Year.

    Additional things that I will record is maintenance/servicing, insurance
    etc etc.

    The vehicles are a bit varied,: Cars, truck, trailer, motorbikes, caravan.

    For these there are different servicing scheduels and I would like to
    include them individually.

    I have tabs for registration, servicing, insurance, Wheels&tyres etc.

    Because of the differences in servicing, I have created 4 subforms for that.

    Now I would like to find a way that will load the correct subform when I
    load each record in the main form. I had thought that I could make a
    col. called ServiceType with a dropdown with options 1, 2, 3 and 4 and
    somehow have the correct subform reference this column then load.

    Any thoughts on how to go about something like this.


    With Thanks
    Rob
  • Keith Wilby

    #2
    Re: Have a different subforms load depending on cell in a record of the parent form

    "Rob" <dy@woodyallan. bizwrote in message
    news:cBhEk.1883 $sc2.1081@news-server.bigpond. net.au...
    >I am putting together a small Access 2003 DB to record details of our
    >motorvehicle s. (this is more to teach myself some basics with Access)
    >
    The main form is holding data that is common to most vehicles. Eg.
    Registration date, expiry, VIN/Chassis, Make, Model, Year.
    >
    Additional things that I will record is maintenance/servicing, insurance
    etc etc.
    >
    The vehicles are a bit varied,: Cars, truck, trailer, motorbikes, caravan.
    >
    For these there are different servicing scheduels and I would like to
    include them individually.
    >
    I have tabs for registration, servicing, insurance, Wheels&tyres etc.
    >
    Because of the differences in servicing, I have created 4 subforms for
    that.
    >
    Now I would like to find a way that will load the correct subform when I
    load each record in the main form. I had thought that I could make a col.
    called ServiceType with a dropdown with options 1, 2, 3 and 4 and somehow
    have the correct subform reference this column then load.
    >
    Any thoughts on how to go about something like this.
    >
    I would have thought that some code in your form's Current event would do
    this, something along the lines of:

    If Me.txtVehicleTy pe = "Car" Then
    Me.MySubformObj ectName.SourceO bject = "sfrmCar"
    ElseIf ...

    .... and so on. You'd probably have to set the LinkMasterField s and
    LinkChildFields properties too.

    Regards,
    Keith.


    Comment

    • Salad

      #3
      Re: Have a different subforms load depending on cell in a recordof the parent form

      Keith Wilby wrote:
      "Rob" <dy@woodyallan. bizwrote in message
      news:cBhEk.1883 $sc2.1081@news-server.bigpond. net.au...
      >
      >I am putting together a small Access 2003 DB to record details of our
      >motorvehicle s. (this is more to teach myself some basics with Access)
      >>
      >The main form is holding data that is common to most vehicles. Eg.
      >Registration date, expiry, VIN/Chassis, Make, Model, Year.
      >>
      >Additional things that I will record is maintenance/servicing,
      >insurance etc etc.
      >>
      >The vehicles are a bit varied,: Cars, truck, trailer, motorbikes,
      >caravan.
      >>
      >For these there are different servicing scheduels and I would like to
      >include them individually.
      >>
      >I have tabs for registration, servicing, insurance, Wheels&tyres etc.
      >>
      >Because of the differences in servicing, I have created 4 subforms for
      >that.
      >>
      >Now I would like to find a way that will load the correct subform when
      >I load each record in the main form. I had thought that I could make
      >a col. called ServiceType with a dropdown with options 1, 2, 3 and 4
      >and somehow have the correct subform reference this column then load.
      >>
      >Any thoughts on how to go about something like this.
      >>
      >
      I would have thought that some code in your form's Current event would
      do this, something along the lines of:
      >
      If Me.txtVehicleTy pe = "Car" Then
      Me.MySubformObj ectName.SourceO bject = "sfrmCar"
      ElseIf ...
      >
      ... and so on. You'd probably have to set the LinkMasterField s and
      LinkChildFields properties too.
      >
      Regards,
      Keith.
      www.keithwilby.com
      It might be easier for the op to have a command button called Servicing
      Schedule and based on the type of vehicle open a separate form depending
      on the type.

      Comment

      • Keith Wilby

        #4
        Re: Have a different subforms load depending on cell in a record of the parent form

        "Salad" <oil@vinegar.co mwrote in message
        news:A76dnYAb_M sjqn_VnZ2dnUVZ_ uGdnZ2d@earthli nk.com...
        Keith Wilby wrote:
        >
        >"Rob" <dy@woodyallan. bizwrote in message
        >news:cBhEk.188 3$sc2.1081@news-server.bigpond. net.au...
        >>
        >>>
        >>Any thoughts on how to go about something like this.
        >>>
        >>
        >I would have thought that some code in your form's Current event would do
        >this, something along the lines of:
        >>
        >If Me.txtVehicleTy pe = "Car" Then
        > Me.MySubformObj ectName.SourceO bject = "sfrmCar"
        >ElseIf ...
        >>
        >... and so on. You'd probably have to set the LinkMasterField s and
        >LinkChildField s properties too.
        >>
        >Regards,
        >Keith.
        >www.keithwilby.com
        >
        It might be easier for the op to have a command button called Servicing
        Schedule and based on the type of vehicle open a separate form depending
        on the type.
        I agree it's a bit fiddly to get it working but is quite slick when it is.

        Comment

        Working...