Requery Problems

  • Thread starter Karen & Kevin Martin
  • Start date
K

Karen & Kevin Martin

Hi

I can't get this requery to work.
I have a form for new records called Records, it contains a subform
called ArticleAuthor which has a Combobox called Author. If the required
Author is not within the list I have a button which opens a New Author Form.
Now when I fill out the details for the New Author, on AfterUpdate, I
want to requery the Author Combobox on the subform.

Any ideas on this, as I am getting confused?

Kevin Martin
 
R

Ron Weiner

Kevin

If your combobox is called Author then adding Author.Requery will cause the
combo to re-retrive all of the records specified by the combos recordsource.
The only tricky part about this is would be refering to the combo control
from somwhere other than the form where it lives. Here is a link that
explains how to refer to objects on forms and subforms.
http://www.mvps.org/access/forms/frm0031.htm

Ron W
 
R

Roger Carlson

On my website are two small sample databases that might help:
"NotInList.mdb" and "SubformReference.mdb"
 
K

Karen & Kevin Martin

Ron said:
Kevin

If your combobox is called Author then adding Author.Requery will cause the
combo to re-retrive all of the records specified by the combos recordsource.
The only tricky part about this is would be refering to the combo control
from somwhere other than the form where it lives. Here is a link that
explains how to refer to objects on forms and subforms.
http://www.mvps.org/access/forms/frm0031.htm

Ron W

Thanks Ron

However, on trying this I am getting the error message

"Runtime error 2465"
cannot find the field 'ArticleAuthorSubform' referred to in your expression

with the following code


Private Sub Form_AfterUpdate()
Forms![Add Record]!ArticleAuthorSubform.Form!Author.Requery
End Sub

Why does it say FIELD when I am trying to refer to a form?

TIA

Kevin Martin
 
R

Ron Weiner

Kevin

Instead of

Forms![Add Record]!ArticleAuthorSubform.Form!Author.Requery

Try something like

Me.ArticleAuthorSubform.Form.Author.Requery

I am assuming that ArticleAuthorSubform is the Subform OBJECT (not the
subform itself)on the form from which you making the call. Me is the
shorthand way of saying Forms!FormName

Ron W

Karen & Kevin Martin said:
Ron said:
Kevin

If your combobox is called Author then adding Author.Requery will cause the
combo to re-retrive all of the records specified by the combos recordsource.
The only tricky part about this is would be refering to the combo control
from somwhere other than the form where it lives. Here is a link that
explains how to refer to objects on forms and subforms.
http://www.mvps.org/access/forms/frm0031.htm

Ron W

Thanks Ron

However, on trying this I am getting the error message

"Runtime error 2465"
cannot find the field 'ArticleAuthorSubform' referred to in your expression

with the following code


Private Sub Form_AfterUpdate()
Forms![Add Record]!ArticleAuthorSubform.Form!Author.Requery
End Sub

Why does it say FIELD when I am trying to refer to a form?

TIA

Kevin Martin
 
K

Karen & Kevin Martin

Ron said:
Kevin

Instead of

Forms![Add Record]!ArticleAuthorSubform.Form!Author.Requery

Try something like

Me.ArticleAuthorSubform.Form.Author.Requery

I am assuming that ArticleAuthorSubform is the Subform OBJECT (not the
subform itself)on the form from which you making the call. Me is the
shorthand way of saying Forms!FormName

Ron W
Hi Ron

Thanks for your help so far, but are you sure I should be using Me. My
understanding is that if you are referring to a different form it should
be Forms!


I was going to ask for further help, but while doing further tests, I
have got it working at LAST, the code by the way was

Forms![Add Record]![Article/Author Subform].Form.Author.Requery

Thanks for your help

Kevin
 
R

Ron Weiner

Glad you got it to work. Me is the shortcut way the form the I am currentyt
on. So it the name of the form that the code is currently running on is
Form1 then I could refer to it as Me. or Forms!Form1.

Ron W
Karen & Kevin Martin said:
Ron said:
Kevin

Instead of

Forms![Add Record]!ArticleAuthorSubform.Form!Author.Requery

Try something like

Me.ArticleAuthorSubform.Form.Author.Requery

I am assuming that ArticleAuthorSubform is the Subform OBJECT (not the
subform itself)on the form from which you making the call. Me is the
shorthand way of saying Forms!FormName

Ron W
Hi Ron

Thanks for your help so far, but are you sure I should be using Me. My
understanding is that if you are referring to a different form it should
be Forms!


I was going to ask for further help, but while doing further tests, I
have got it working at LAST, the code by the way was

Forms![Add Record]![Article/Author Subform].Form.Author.Requery

Thanks for your help

Kevin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top