MS Access Forum / Forms Programming / March 2007
What does it mean FOrm ins't open, when it is open?
|
|
Thread rating:  |
efandango - 23 Mar 2007 23:36 GMT When I try to run the code below, i get an error message saying
"The object 'Forms!Runs!frm_Run_Test' isn't open
I don't understand, because the form is actually open?
The code below is to take a value from one form and pass it to a control on another form, both forms are on the same tab page, both forms are Subforms on a master 'Runs' Form. They are positioned side-by-side, and i can see them both, so how come Access say's it's not open?
The Code on the selector form that passes the contents of 'Waypoint_Selector' to the field 'Waypoint_Combo' on the target form/field. The code errrors on this line: DoCmd.GoToRecord acDataForm, "Forms!Runs!frm_Run_Test", acNext
Private Sub Waypoint_Selector_Click()
If IsNull(Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo]) Then Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo] = Me.Waypoint_Selector Else DoCmd.GoToRecord acDataForm, "Forms!Runs!frm_Run_Test", acNext End If
George Nicholson - 24 Mar 2007 00:30 GMT A form opened as a subform isn't an open Form. A form has to be open in a stand-alone mode for it to be recognized as Open.
Please look at: Refer to Form and Subform properties and controls http://mvps.org/access/forms/frm0031.htm
Note that the Form name is 100% useless when establishing a reference to a subform. You must use the name of the Control *containing* the subform. If you used drag & drop or a wizard to place the subform these 2 objects *may* have the same names, but you should treat that as simple coincidence because you can't rely on it always being the case. It is crucial that you are aware of the distinction or you might be spinning your wheels forever.
HTH,
> When I try to run the code below, i get an error message saying > [quoted text clipped - 24 lines] > > End If Marshall Barton - 24 Mar 2007 00:36 GMT >When I try to run the code below, i get an error message saying > [quoted text clipped - 20 lines] > >End If A form displayed by a subform control is not a member of the Forms collection so there is no way to refer to it using that mechanism.
You can navigate the records in one subform using this kind of logic in the other subform:
Parent.RunTestsubformcontrol.SetFocus Me.RunTestsubformcontrol.Form.Waypoint_Combo.SetFocus RunCommand acCmdRecordsGoToNew
 Signature Marsh MVP [MS Access]
efandango - 24 Mar 2007 17:20 GMT Marsh,
I tried a variation on your code, like this:
Parent.frm_RunTest.subformcontrol.SetFocus Me.frm_RunTest.subformcontrol.Form.Waypoint_Combo.SetFocus RunCommand acCmdRecordsGoToNew
i just put some periods in because I assumed you missed them out for seperating fields, also the form name is actually frm_Run_Test. however, either way doesn't work. With my version above i get:
Compile Error: Method or Data Member not found
with your original version i get the same error message:
I really don't get it?
> >When I try to run the code below, i get an error message saying > > [quoted text clipped - 31 lines] > Me.RunTestsubformcontrol.Form.Waypoint_Combo.SetFocus > RunCommand acCmdRecordsGoToNew Marshall Barton - 24 Mar 2007 18:31 GMT Extra dots are not appropriate. Changing my guess at your subform control name was the key thing you needed to do (in addition to my mistake in using Me). Since you did not provide the name of the subform control that is used to display the form object frm_RunTest, I made up a name to indicate what you needed to replace it with. ** IF** your subform control has the same name as its displayed form object, then the code would be:
Parent.frm_RunTest.SetFocus Parent.frm_RunTest.Form.Waypoint_Combo.SetFocus RunCommand acCmdRecordsGoToNew
 Signature Marsh MVP [MS Access]
>I tried a variation on your code, like this: > [quoted text clipped - 8 lines] >Compile Error: >Method or Data Member not found
>> >When I try to run the code below, i get an error message saying >> > [quoted text clipped - 31 lines] >> Me.RunTestsubformcontrol.Form.Waypoint_Combo.SetFocus >> RunCommand acCmdRecordsGoToNew efandango - 24 Mar 2007 21:35 GMT Marshall I have finally CRACKED IT!, with a huge dollop of your generous help for which I am most grateful for.
Here's my working code.
Private Sub Waypoint_Selector_Click()
If IsNull(Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo]) Then Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo] = Me.Waypoint_Selector Else Parent.frm_Run_Test.SetFocus Parent.frm_Run_Test.Form.Waypoint_Combo.SetFocus RunCommand acCmdRecordsGoToNext
If IsNull(Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo]) Then Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo] = Me.Waypoint_Selector End If
End If
End Sub
Can you tell me how I can get the following routine into my code which should kick-in when the user exhausts all avaliable empty fields.
Else MsgBox "All fields are filled" End If
I am trying to place this in, but I get a combination of different, If, or block of errors, no matter what permuation I use I can’t seem to get it to work.
Meanwhile, thanks for your help.
> Extra dots are not appropriate. Changing my guess at your > subform control name was the key thing you needed to do (in [quoted text clipped - 56 lines] > >> Me.RunTestsubformcontrol.Form.Waypoint_Combo.SetFocus > >> RunCommand acCmdRecordsGoToNew Marshall Barton - 25 Mar 2007 05:48 GMT >Marshall I have finally CRACKED IT!, with a huge dollop of your generous help >for which I am most grateful for. [quoted text clipped - 22 lines] > MsgBox "All fields are filled" >End If Well, aside from the fact that I don't fully undestand what you are trying to accomplish here, I don't think I like that code very much.
Whar's with the part about if the current record is filled in, put the value in the next record? What if that one is filled in too? Are you supposed to search down the form for a record that's not filled in? Or is the user supposed to select the record to fill in first? Maybe the user is allowed to select a record and all you want to do is move to the next record after the value is filled in the current record??
Whatever it is, as long as you do not want to go to a new record, we should not be messing with the focus unless it's absolutely necessary. This kind of code is more to the point about moving to the next record:
With Parent.frm_Run_Test.Form.Recordset If Not .EOF Then If IsNull( Signature Marsh MVP [MS Access]
efandango - 24 Mar 2007 18:29 GMT Marshall,
Will this help give you an idea of my setup?
MY Main Form is called: Runs My Target Subform is Called: frm_Run_Test My Target Control is Called: AnswerWaypoint
My Selection form (that i get the data from) is called: frm_Run_Test_Selector My Selection Field is called: Waypoint_Selector
Both Forms are on the Main Form: Runs
as previously mentioned, i want to place the data from one datafield on a different form in the next available empty field on the subform, i don't want a new record, as such; because the rest of the record is filled in, it is just this missing data field that is blank, so presumably i want to use to find the next available empty field with the change to your code below using:
RunCommand acCmdRecordsGoToNext instead of RunCommand acCmdRecordsGoToNew
I can get it to work for the first data field, and if i manually go to the next empty Target field and place a cursor in it, then hit the action button on the Selector Form, it works, just fine, so my only stumbling block is not ebing able to move to the next empty field.
> >When I try to run the code below, i get an error message saying > > [quoted text clipped - 31 lines] > Me.RunTestsubformcontrol.Form.Waypoint_Combo.SetFocus > RunCommand acCmdRecordsGoToNew efandango - 24 Mar 2007 21:07 GMT Marhsall,
I pasted your code in like this:
Private Sub Waypoint_Selector_Click()
If IsNull(Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo]) Then Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo] = Me.Waypoint_Selector Else Parent.frm_RunTest.SetFocus Parent.frm_RunTest.Form.Waypoint_Combo.SetFocus RunCommand acCmdRecordsGoToNew
End If End Sub
But i can an error message: Application-defined or object-defined error
also, how can i incorporate this line:
DoCmd.GoToRecord acDataForm, Forms!Runs!frm_Run_Test.Form! [Waypoint_Combo], acNext
which i believe should take me to the next available empty 'Waypoint_Combo' field, or does your code take care of that?, only it seems that the fragment 'acCmdRecordsGoToNew' in your code seems to suggest that it will create a new record (which would not be what i need as i already have the records, except for the missing cruical address text.
> Marshall, > [quoted text clipped - 59 lines] > > Me.RunTestsubformcontrol.Form.Waypoint_Combo.SetFocus > > RunCommand acCmdRecordsGoToNew efandango - 24 Mar 2007 21:18 GMT Marshall ignore the last 'Error Message' post, it was a case of reinstating the underscore in: 'frm_Run_Test'
But now that has been resolved, I get a different error message:
Run-time error 2046
The command or action 'RecordsGoToNew' ins't available now.
> When I try to run the code below, i get an error message saying > [quoted text clipped - 20 lines] > > End If efandango - 28 Mar 2007 00:05 GMT Marshall, I have a different problem now. So far the Form works, in that I can 'pick and place' from the Selector Form/Control to the Target Form/Control, but now I need a way of dealing with the incorrect entry. What I want to happen is nothing. Just leave the available field empty, and… available for the next attempt at getting it right. I suppose what I am asking is the possibility of having an ‘If’ multiple condition, but I can’t seem to code for that scenario.
Which would be something like:
If the target field is blank AND the target field is the correct match
Then fill it it. If not, just leave it available for antother try.
I have tried to do something with the AfterUpdate of the Target Control but though it seems to have the focus, it doesn't respond as if it doesn't have the focus.
> Marshall ignore the last 'Error Message' post, it was a case of reinstating > the underscore in: 'frm_Run_Test' [quoted text clipped - 29 lines] > > > > End If Marshall Barton - 28 Mar 2007 18:20 GMT >I have a different problem now. So far the Form works, in that I can 'pick >and place' from the Selector Form/Control to the Target Form/Control, but now [quoted text clipped - 14 lines] >though it seems to have the focus, it doesn't respond as if it doesn't have >the focus. More information please.
What does your code look like now?
What do you mean by "target field is the correct match"?
 Signature Marsh MVP [MS Access]
|
|
|