I have that on form load and I get an error message that I can't assign a value to the object. :-(
make sure data is entered before going to new form?
Collapse
X
-
-
-
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
-
Originally posted by DenburtIt 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.
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
-
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 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
-
Originally posted by NeoPaIn 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 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.
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
-
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
-
-
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
Comment