make sure data is entered before going to new form?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AccessIdiot
    Contributor
    • Feb 2007
    • 493

    #31
    I have that on form load and I get an error message that I can't assign a value to the object. :-(

    Comment

    • Denburt
      Recognized Expert Top Contributor
      • Mar 2007
      • 1356

      #32
      Sorry I wasn't more clear that would go into the open event.

      Code:
      Private Sub Form_Open(Cancel As Integer)
      If not IsNull(Me.OpenArgs) Then
               me!Replicate_ID = Me.OpenArgs
      End if

      Comment

      • AccessIdiot
        Contributor
        • Feb 2007
        • 493

        #33
        lol, it doesn't like that one either.

        Comment

        • Denburt
          Recognized Expert Top Contributor
          • Mar 2007
          • 1356

          #34
          It has to be something simple that is being overlooked. If you can add a value to that field manually then there is no reason you can't do it the way we have it in code.

          Comment

          • AccessIdiot
            Contributor
            • Feb 2007
            • 493

            #35
            I agree but I am at a loss as to where to look! Any ideas on what would cause the error? Is there something that is blocking the assignment that I could look into? Could it be conflicting with some other event?

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32634

              #36
              Originally posted by Denburt
              It has to be something simple that is being overlooked. If you can add a value to that field manually then there is no reason you can't do it the way we have it in code.
              Yes there is. It's a timing issue.
              I had a (v v) long discussion with Mary the other day about this sort of thing and it will not be allowed at that stage (OnOpen) due to the form not yet having a current record (I think). Clearly an unbound control will not have the same restrictions.

              Melissa,
              Can I ask how we got from using subforms - where we were a couple of weeks ago (Separate thread and including sending me a copy of the db) - to using separate forms for this? As discussed, it is much harder to implement (than doing the whole process using subforms). Not impossible, as there are some quite complex work-arounds, but possibly a bridge too far for your current stage of understanding.
              BTW Master & Child linked fields (that make the whole process work so smoothly for subforms), are not available for separately called forms.

              If we need to, we can get you through this but we will need to be very disciplined in our communication as we are talking some fairly convoluted concepts here and if we get out of step between ourselves then we will all just get confused (Notice the difficulty of communication within this very thread).

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32634

                #37
                In short, you need to save the current record of your existing form first before opening the new one passing the OpenArgs.
                Code:
                DoCmd.RunCommand acCmdSaveRecord
                In the OnOpen event procedure you need to store the OpenArgs value.
                In the OnCurrent you could do something like setting the bound control to the passed value then immediately setting the Dirty flag to False.
                Check that your bound controls are properly set up though. They should not be set explicitly to a data source as the data source for all the bound controls on the form should be the datasource that the form itself is bound to.

                Comment

                • AccessIdiot
                  Contributor
                  • Feb 2007
                  • 493

                  #38
                  Originally posted by NeoPa
                  In short, you need to save the current record of your existing form first before opening the new one passing the OpenArgs.
                  Code:
                  DoCmd.RunCommand acCmdSaveRecord
                  In the OnOpen event procedure you need to store the OpenArgs value.
                  In the OnCurrent you could do something like setting the bound control to the passed value then immediately setting the Dirty flag to False.
                  Check that your bound controls are properly set up though. They should not be set explicitly to a data source as the data source for all the bound controls on the form should be the datasource that the form itself is bound to.
                  Hey NeoPa thanks for stepping in. It makes sense that timing could be an issue, I've seen the same thing in Flash.

                  You asked about forms and subforms - I did do that successfully but now I am onto a different table/form. To create another nested subform inside the current subform would take up too much screen space. Would it work to use tabs? I could see that happening if working with forms is too difficult.

                  My project has multiple forms, some are used and some are not. Here is how it is currently setup:

                  1) User is presented with a main menu form with buttons. User clicks a button and is taken to

                  2) a survey form. When they click a button on the survey form it enables

                  3) a replicate subform within the survey form. On the replicate subform they can click a button to enter data about specimens that were caught during the replicate. Clicking the button takes them to

                  4) the specimen form. If the specimen they have caught is not in the species drop down combo box they can type it in and the NotInList function will

                  5) open a species form.

                  So you see there are lots of steps and a variety of forms. Every survey will have a replicate. Not every replicate will have specimen data so it has to be optional not required. But since there can be more than one specimen per replicate the replicate id has to get into the specimen table.

                  I can sort of follow your suggestions on code but am a little lost on the dirty flag and not really sure what you mean by bound controls not being set to a datasource. I have some controls bound to a table such as Staff that feeds the dropdown. Then the choice is stored in the foreign key in the table that feeds the form. For example the combo box is sourced by Staff.StaffID but the choice made by the user is stored in Replicate.Staff ID.

                  I hope this is something I can resolve soon. The guys I"m building this database for are chomping at the bit and I told them I'd hopefully have the problem fixed by the end of the week! So please let me know if there is another way I should be approaching this. Should I maybe have "stacked" subforms that become visible when needed? Would that be easier to code?

                  Comment

                  • NeoPa
                    Recognized Expert Moderator MVP
                    • Oct 2006
                    • 32634

                    #39
                    Great response Melissa.
                    Will have to give this some thought.
                    Can you send me your latest version in the mean-time. This will help me when I'm trying to understand all you've said. It should fill in the context for me. I can forward it on to denburt too, if he expresses a wish to receive it.

                    Comment

                    • AccessIdiot
                      Contributor
                      • Feb 2007
                      • 493

                      #40
                      Much appreciated! Will compact and send along momentarily.

                      Comment

                      • Denburt
                        Recognized Expert Top Contributor
                        • Mar 2007
                        • 1356

                        #41
                        I'll be in and out but would be glad to look at it. Anything I can do to help. :)

                        Comment

                        • AccessIdiot
                          Contributor
                          • Feb 2007
                          • 493

                          #42
                          I really REALLY appreciate it. I have sent it to NeoPa and am happy to send it to you if you pm me your email address.

                          cheers!

                          Comment

                          • NeoPa
                            Recognized Expert Moderator MVP
                            • Oct 2006
                            • 32634

                            #43
                            Originally posted by AccessIdiot
                            Much appreciated! Will compact and send along momentarily.
                            Marvellous!
                            I won't get home for a while mind you, but it's good to know it'll be there before I am :D

                            Comment

                            • NeoPa
                              Recognized Expert Moderator MVP
                              • Oct 2006
                              • 32634

                              #44
                              Originally posted by Denburt
                              I'll be in and out but would be glad to look at it. Anything I can do to help. :)
                              Unless I hear to the contrary, I'll forward it straight on to you as soon as I get in, and on my PC tonight Denburt.

                              Comment

                              • NeoPa
                                Recognized Expert Moderator MVP
                                • Oct 2006
                                • 32634

                                #45
                                Database forwarded :)

                                Comment

                                Working...