Subform refresh and query view.
Collapse
X
-
I am looking for the "control" of the subform. As far as the code, that is all there is, well except for this;
Which is just above;Code:Option Compare Database Private Sub addrecord_Click()
Code:# On Error GoTo Err_addrecord_Click # # DoCmd.GoToRecord , , acNewRec
Comment
-
The SubForm IS a control.
It looks like the name of your SubForm control may be [historyrequest subform]. It's hard to be sure from the code if you've used spaces in your names. It's best to look at the design of the form to find the name of the control. Open the Properties Pane (Alt-Enter) and look at the name when you select the control.Comment
-
Okay, I deleted the subform and started from scratch. In the form "tolog" I created a subform using the wizard. I asked the wizard to use query "historyrequest " to populate the subform. The query gets the records for the past 24hrs from table "tolog" to display in the subform. When doing Alt+Enter with the subform selected, the name is "historyrequest subform" this is also the name I gave it in the wizard. Now I went to "tologentry " which is the form used to input records into "tolog" table. In the OnClose event for the form I inserted the following;
Should this not refresh the subform?Code:Option Compare Database Private Sub Form_Close() historyrequestsubform.Form.Requery End Sub
I am getting the following error;
Run-time error '424':
Object Required
When I select debug and the code window emerges, the historyrequests ubform.Form.Req uery is highlighted with an arrow pointing to it.Comment
-
Okay, I tried the above and did not work. Since I may have had some naming issues, I deleted the whole project (it was small so no worry there) and started again. Now, I recreated the tables and forms and inside of "FormToLog" is "SubFormShowPas tDay" which displays past 24hr records using "QueryPastD ay".
Also in "FormToLog" I have a button, this button calls up "FormNewLogEntr y" from this form records are added to "TableLogEntrie s". In the OnClose event of "FormNewLogEntr y" I inserted the following code;
When I close "FormNewLogEntr y" I get the errorCode:Private Sub Form_Close() Me.SubFormShowPastDay.Form.Requery End Sub
"Compile Error: Method or data member not found"
when the VB window is opened after choosing "Debug" .SubFormShowPas tDay is highlited in blue, not the usual yellow.
If I open "FormToLog" in design view, and choose "SubFormShowPas tDay" (I.e. it has the edit form highlight) and do Alt+Enter in the subsequent window titled "Subform/Subreport: SubFormShowPast Day" under Data tab in the field Source Object "SubFormShowPas tDay" is displayed. Under the Other tab in the field Name "SubFormShowPas tDay" is displayed. So, am I correct the subform control is "SubFormShowPas tDay" ?
If I remove "Me." from the above code, then the following error is displayed;
"Run-timer error '424': Object required"
Upon selecting Debug the VB window displays the event with the line "SubFormShowPas tDay.Form.Reque ry" highlighted in yellow with a yellow arrow pointing to it.
I dont know what other information to give to help solve the problem or pinpoint my error :(. I may just have to create a button to refresh "FormToLog" for the user to refresh the records display in "SubFormShowPas tDay"
All help appreciated..." Help me ObeeWan, You're my only hope" :)
Regards,Comment
-
Note that it is a good idea to check that the form you want to reference is open before you go and try to use it. To prevent errors, you can do something like:
Code:If CurrentProject.AllForms("FormToLog").IsLoaded Then 'Do your stuff End IfComment
-
OMG!
ChipR for the win.
That was the Michael Jordan shot.
May your life be blessed with the fruit of Laurelin.
Thanks everyone for the help. What a great place.
Now if I may ask, with that code you are actually pointing the requery to go to the subform in "FormToLog" , where as with the previous code it was assuming that the subform was within "FormNewLogEntr y"?
I just want to edumacate myself, if possible, not just plug in a code and "voila" it works.
Again, thank you all for everything. Hope not to bug you too much again.
Regards,Comment
-
I haven't the time to check through the logic of this now, but I think you can assume Chip has the solution for you. He's pretty sound.
If you still experience problems then let us know. I'll check back later when I have a little more time.Comment
-
Sorry, didn't catch this earlier.
Absolutely.
PS. You're welcome to post your queries in future. That's what we're here for :)Comment
-
If you're patient, and it seems you are, you should find this link very useful:
Access Object Model Reference.Comment
-
Me too. That's going into my Bytes database :)If you're patient, and it seems you are, you should find this link very useful:
Access Object Model Reference.Comment
Comment