Requery not!

C

Chris

I am unable to update the data in a subform. I have the code attached to a
close button on a popup form.

Code follows:
Using Forms![formname]![subformname].requery
DoCmd.close

The form "formname" is open throughout. I requery it and it disappears. I
would really like to requery the subform successfully. I am using the name
of the subform, not the name of the form used as the subform.

Is there something I am missing here?

Thanks.
Chrissy
 
K

Klatuu

Your syntax is incorrect.
Using Forms![formname]![subformname].requery

Should be:
Forms![formname]![subformControlname].Form.requery

Note, subformControlname is the name of the subform control on your form,
not the name of the form identified as the Source Object in the subform
control's properties.
 
C

Chris

Dave - thanks for the response.

I am using the control name, sorry for the confusion. However, I did leave
out the "form" prior to "requery".

I have corrected, using the following code, and still no joy.

Forms![formname]![subformcontrolname].Form.Requery


--
Thanks for your help,
Chrissy


Klatuu said:
Your syntax is incorrect.
Using Forms![formname]![subformname].requery

Should be:
Forms![formname]![subformControlname].Form.requery

Note, subformControlname is the name of the subform control on your form,
not the name of the form identified as the Source Object in the subform
control's properties.
--
Dave Hargis, Microsoft Access MVP


Chris said:
I am unable to update the data in a subform. I have the code attached to a
close button on a popup form.

Code follows:
Using Forms![formname]![subformname].requery
DoCmd.close

The form "formname" is open throughout. I requery it and it disappears. I
would really like to requery the subform successfully. I am using the name
of the subform, not the name of the form used as the subform.

Is there something I am missing here?

Thanks.
Chrissy
 
K

Klatuu

Are you getting an error? Is so, what?
Are you doing this from a different form? If so, are you doing it because
the data in the current form will affect the recordset in the form you want
to requery? If so, have you tried requerying the current form first?

If none of this applies, please describe the circumstances.
--
Dave Hargis, Microsoft Access MVP


Chris said:
Dave - thanks for the response.

I am using the control name, sorry for the confusion. However, I did leave
out the "form" prior to "requery".

I have corrected, using the following code, and still no joy.

Forms![formname]![subformcontrolname].Form.Requery


--
Thanks for your help,
Chrissy


Klatuu said:
Your syntax is incorrect.
Using Forms![formname]![subformname].requery

Should be:
Forms![formname]![subformControlname].Form.requery

Note, subformControlname is the name of the subform control on your form,
not the name of the form identified as the Source Object in the subform
control's properties.
--
Dave Hargis, Microsoft Access MVP


Chris said:
I am unable to update the data in a subform. I have the code attached to a
close button on a popup form.

Code follows:
Using Forms![formname]![subformname].requery
DoCmd.close

The form "formname" is open throughout. I requery it and it disappears. I
would really like to requery the subform successfully. I am using the name
of the subform, not the name of the form used as the subform.

Is there something I am missing here?

Thanks.
Chrissy
 
C

Chris

There ya go!

I requeried the changed form first...and all is well.

Thank you so much for helping me.

Chrissy


Klatuu said:
Are you getting an error? Is so, what?
Are you doing this from a different form? If so, are you doing it because
the data in the current form will affect the recordset in the form you want
to requery? If so, have you tried requerying the current form first?

If none of this applies, please describe the circumstances.
--
Dave Hargis, Microsoft Access MVP


Chris said:
Dave - thanks for the response.

I am using the control name, sorry for the confusion. However, I did leave
out the "form" prior to "requery".

I have corrected, using the following code, and still no joy.

Forms![formname]![subformcontrolname].Form.Requery


--
Thanks for your help,
Chrissy


Klatuu said:
Your syntax is incorrect.
Using Forms![formname]![subformname].requery

Should be:
Forms![formname]![subformControlname].Form.requery

Note, subformControlname is the name of the subform control on your form,
not the name of the form identified as the Source Object in the subform
control's properties.
--
Dave Hargis, Microsoft Access MVP


:

I am unable to update the data in a subform. I have the code attached to a
close button on a popup form.

Code follows:
Using Forms![formname]![subformname].requery
DoCmd.close

The form "formname" is open throughout. I requery it and it disappears. I
would really like to requery the subform successfully. I am using the name
of the subform, not the name of the form used as the subform.

Is there something I am missing here?

Thanks.
Chrissy
 
K

Klatuu

Glad I could help.
Here is what was causing your problem.
When you add or update a record in your form's recordset, it does not go
directly to the table. It exists only in the form's recordset until you
requery the form. That is why it would not show in the other form.
--
Dave Hargis, Microsoft Access MVP


Chris said:
There ya go!

I requeried the changed form first...and all is well.

Thank you so much for helping me.

Chrissy


Klatuu said:
Are you getting an error? Is so, what?
Are you doing this from a different form? If so, are you doing it because
the data in the current form will affect the recordset in the form you want
to requery? If so, have you tried requerying the current form first?

If none of this applies, please describe the circumstances.
--
Dave Hargis, Microsoft Access MVP


Chris said:
Dave - thanks for the response.

I am using the control name, sorry for the confusion. However, I did leave
out the "form" prior to "requery".

I have corrected, using the following code, and still no joy.

Forms![formname]![subformcontrolname].Form.Requery


--
Thanks for your help,
Chrissy


:

Your syntax is incorrect.
Using Forms![formname]![subformname].requery

Should be:
Forms![formname]![subformControlname].Form.requery

Note, subformControlname is the name of the subform control on your form,
not the name of the form identified as the Source Object in the subform
control's properties.
--
Dave Hargis, Microsoft Access MVP


:

I am unable to update the data in a subform. I have the code attached to a
close button on a popup form.

Code follows:
Using Forms![formname]![subformname].requery
DoCmd.close

The form "formname" is open throughout. I requery it and it disappears. I
would really like to requery the subform successfully. I am using the name
of the subform, not the name of the form used as the subform.

Is there something I am missing here?

Thanks.
Chrissy
 
D

Dirk Goldgar

Klatuu said:
Glad I could help.
Here is what was causing your problem.
When you add or update a record in your form's recordset, it does not go
directly to the table. It exists only in the form's recordset until you
requery the form. That is why it would not show in the other form.

I don't know if a full requery of the popup form is necessary here. It
seems likely to me that simply forcing the current record to be saved would
do the trick; e.g.,

If Me.Dirty Then Me.Dirty = False
Forms![FormName]![SubformControlName].Requery
DoCmd.Close acForm, Me.Name, acSaveNo

Also, it shouldn't actually be necessary to insert the ".Form" qualifier
after the [SubformControlName], as requerying a subform control is supposed
to requery the form object it displays. That said, I've heard that either
A2003 or A2007 has gotten very picky about some of these references, so I'm
not 100% sure that still holds true.
 
K

Klatuu

You are correct about updating the record. Didn't think about that.

Using AC03 with SP3, I have found it necessary to use the Form qualifier.

Also encountered a problem recently with Me.Dirty = False

If I coded:

If Me.Dirty Then
Me.Dirty = False
End If

and I use the form BeforeUpdate it will update the record if it passes the
tests in Before Update. If, however, I cancel the update, It starts throwing
errors. First is says I can't assign a value to this object on the Me.Dirty
= False line. If I try in debug to make the next line Me.Dirty = False and
execute it again, I get No Current Record. It was on an SQL Server 2005
table and I am in mdb. So I tried it on a linked table from an mdb and go
the same problems. My guess is this is an undocumented SP3 issue. I have
use the above technique for a long time and never before had that problem.
--
Dave Hargis, Microsoft Access MVP


Dirk Goldgar said:
Klatuu said:
Glad I could help.
Here is what was causing your problem.
When you add or update a record in your form's recordset, it does not go
directly to the table. It exists only in the form's recordset until you
requery the form. That is why it would not show in the other form.

I don't know if a full requery of the popup form is necessary here. It
seems likely to me that simply forcing the current record to be saved would
do the trick; e.g.,

If Me.Dirty Then Me.Dirty = False
Forms![FormName]![SubformControlName].Requery
DoCmd.Close acForm, Me.Name, acSaveNo

Also, it shouldn't actually be necessary to insert the ".Form" qualifier
after the [SubformControlName], as requerying a subform control is supposed
to requery the form object it displays. That said, I've heard that either
A2003 or A2007 has gotten very picky about some of these references, so I'm
not 100% sure that still holds true.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 

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

Top