A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Requery a form from its subform, then add new



 
 
Thread Tools Display Modes
  #1  
Old February 18th, 2010, 12:33 AM posted to microsoft.public.access.forms
.Len B
external usenet poster
 
Posts: 81
Default Requery a form from its subform, then add new

I have a form with a subform with no navigation buttons.
The subform has a cmdSave button to save the detail record.
In its click event I have
If Not Me.NewRecord Then RunCommand acCmdRecordGoToNew
Me.Parent.Requery

Depending on the order of these two statements I get a
different problem.

If I use the order shown, the RecordGoToNew works but it
is effectively undone by the requery. If I add another
RecordGoToNew line I get error 2046: The command or
action 'RecordGoToNew' isn't available now.

If I switch order I receive the 2046 error.

It seems that a requery prevents the GoToNew from working.

So far I have avoided doing the requery at all but how do I
introduce it without creating a problem?

--
Len
__________________________________________________ ____
remove nothing for valid email address.


  #2  
Old February 18th, 2010, 08:04 AM posted to microsoft.public.access.forms
Jeanette Cunningham
external usenet poster
 
Posts: 2,190
Default Requery a form from its subform, then add new

The way I see it, you would requery the parent form to pick up any new
information that has been added to the table/s the parent form is based on
and then show them on the form.
If you are adding and editing information in the subform, I am not seeing
why there is a need to requery the parent form. Perhfaps there is more to
this than shown in your post.

To go to a new record in the subform, I would use code like this on the save
button
--start of sample code
If Me.Dirty Then
Me.Dirty = False
End If

DoCmd.GoToRecord , ,acNewRec
--end of sample code


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia

".Len B" wrote in message
...
I have a form with a subform with no navigation buttons.
The subform has a cmdSave button to save the detail record.
In its click event I have
If Not Me.NewRecord Then RunCommand acCmdRecordGoToNew
Me.Parent.Requery

Depending on the order of these two statements I get a
different problem.

If I use the order shown, the RecordGoToNew works but it
is effectively undone by the requery. If I add another
RecordGoToNew line I get error 2046: The command or
action 'RecordGoToNew' isn't available now.

If I switch order I receive the 2046 error.

It seems that a requery prevents the GoToNew from working.

So far I have avoided doing the requery at all but how do I
introduce it without creating a problem?

--
Len
__________________________________________________ ____
remove nothing for valid email address.




  #3  
Old February 18th, 2010, 12:01 PM posted to microsoft.public.access.forms
.Len B
external usenet poster
 
Posts: 81
Default Requery a form from its subform, then add new

Hi Jeanette,
I indeed do have Dirty=False earlier in the code followed by a
MsgBox saying "saved" then the RunCommand acCmdRecordGoToNew.

In the bottom half of the main form I have a FlexGrid ActiveX
control which imitates an uneditable subform (datasheet) but
the height of each row varies depending on content. It is this
control that I want to update with the detail record just saved,
whilst leaving the true subform available and ready to enter a
brand new detail record. In fact the subform has no navigation
buttons so that the user cannot access earlier detail records
to edit (or even view) them.

I haven't tested the DoCmd.GoToRecord variation yet to see if
it also errors with a 2046.

--
Len
__________________________________________________ ____
remove nothing for valid email address.
"Jeanette Cunningham" wrote in message
...
| The way I see it, you would requery the parent form to pick up any new
| information that has been added to the table/s the parent form is based
on
| and then show them on the form.
| If you are adding and editing information in the subform, I am not
seeing
| why there is a need to requery the parent form. Perhfaps there is more
to
| this than shown in your post.
|
| To go to a new record in the subform, I would use code like this on the
save
| button
| --start of sample code
| If Me.Dirty Then
| Me.Dirty = False
| End If
|
| DoCmd.GoToRecord , ,acNewRec
| --end of sample code
|
|
| Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
|
| ".Len B" wrote in message
| ...
| I have a form with a subform with no navigation buttons.
| The subform has a cmdSave button to save the detail record.
| In its click event I have
| If Not Me.NewRecord Then RunCommand acCmdRecordGoToNew
| Me.Parent.Requery
|
| Depending on the order of these two statements I get a
| different problem.
|
| If I use the order shown, the RecordGoToNew works but it
| is effectively undone by the requery. If I add another
| RecordGoToNew line I get error 2046: The command or
| action 'RecordGoToNew' isn't available now.
|
| If I switch order I receive the 2046 error.
|
| It seems that a requery prevents the GoToNew from working.
|
| So far I have avoided doing the requery at all but how do I
| introduce it without creating a problem?
|
| --
| Len
| __________________________________________________ ____
| remove nothing for valid email address.
|
|
|
|



  #4  
Old February 18th, 2010, 12:42 PM posted to microsoft.public.access.forms
.Len B
external usenet poster
 
Posts: 81
Default Requery a form from its subform, then add new

".Len B" wrote in message
...
| Hi Jeanette,
| I indeed do have Dirty=False earlier in the code followed by a
| MsgBox saying "saved" then the RunCommand acCmdRecordGoToNew.
|
| I haven't tested the DoCmd.GoToRecord variation yet to see if
| it also errors with a 2046.


DoCmd.GoToRecord also causes error
2105:You can't go to the specified record.

--
Len
__________________________________________________ ____
remove nothing for valid email address.
|
| --
| Len
| __________________________________________________ ____
| remove nothing for valid email address.



  #5  
Old February 18th, 2010, 10:49 PM posted to microsoft.public.access.forms
Jeanette Cunningham
external usenet poster
 
Posts: 2,190
Default Requery a form from its subform, then add new

Sorry, I don't have any experience with any ActiveX controls - in fact I
stay well away from them as there can be problems with different versions
and references.
I think you would get a better answer if you reposted your question with the
words 'FlexGrid ActiveX' somewhere in the title, so someone with that type
of experience can answer.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia



".Len B" wrote in message
...
Hi Jeanette,
I indeed do have Dirty=False earlier in the code followed by a
MsgBox saying "saved" then the RunCommand acCmdRecordGoToNew.

In the bottom half of the main form I have a FlexGrid ActiveX
control which imitates an uneditable subform (datasheet) but
the height of each row varies depending on content. It is this
control that I want to update with the detail record just saved,
whilst leaving the true subform available and ready to enter a
brand new detail record. In fact the subform has no navigation
buttons so that the user cannot access earlier detail records
to edit (or even view) them.

I haven't tested the DoCmd.GoToRecord variation yet to see if
it also errors with a 2046.

--
Len
__________________________________________________ ____
remove nothing for valid email address.
"Jeanette Cunningham" wrote in message
...
| The way I see it, you would requery the parent form to pick up any new
| information that has been added to the table/s the parent form is based
on
| and then show them on the form.
| If you are adding and editing information in the subform, I am not
seeing
| why there is a need to requery the parent form. Perhfaps there is more
to
| this than shown in your post.
|
| To go to a new record in the subform, I would use code like this on the
save
| button
| --start of sample code
| If Me.Dirty Then
| Me.Dirty = False
| End If
|
| DoCmd.GoToRecord , ,acNewRec
| --end of sample code
|
|
| Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
|
| ".Len B" wrote in message
| ...
| I have a form with a subform with no navigation buttons.
| The subform has a cmdSave button to save the detail record.
| In its click event I have
| If Not Me.NewRecord Then RunCommand acCmdRecordGoToNew
| Me.Parent.Requery
|
| Depending on the order of these two statements I get a
| different problem.
|
| If I use the order shown, the RecordGoToNew works but it
| is effectively undone by the requery. If I add another
| RecordGoToNew line I get error 2046: The command or
| action 'RecordGoToNew' isn't available now.
|
| If I switch order I receive the 2046 error.
|
| It seems that a requery prevents the GoToNew from working.
|
| So far I have avoided doing the requery at all but how do I
| introduce it without creating a problem?
|
| --
| Len
| __________________________________________________ ____
| remove nothing for valid email address.
|
|
|
|





  #6  
Old February 18th, 2010, 11:40 PM posted to microsoft.public.access.forms
.Len B
external usenet poster
 
Posts: 81
Default Requery a form from its subform, then add new

Thanks for your time Jeanette.
It isn't so much the activeX control that I thought needed
updating as the data.

I guess you're saying that the latest detail record is in the
underlying recordset already so a requery isn't necessary.

I'll try a repaint, If that doesn't work, I'll force a redraw of
the ActiveX. I know how to do that ok from the main form. I wrote
the routine to draw it in the first place. It's just that the
parameters I pass are local to the main form, not to the subform
so I thought a requery would do the job more easily.
--
Len
__________________________________________________ ____
remove nothing for valid email address.
"Jeanette Cunningham" wrote in message
...
| Sorry, I don't have any experience with any ActiveX controls - in fact
I
| stay well away from them as there can be problems with different
versions
| and references.
| I think you would get a better answer if you reposted your question
with the
| words 'FlexGrid ActiveX' somewhere in the title, so someone with that
type
| of experience can answer.
|
|
| Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
|
|
|
| ".Len B" wrote in message
| ...
| Hi Jeanette,
| I indeed do have Dirty=False earlier in the code followed by a
| MsgBox saying "saved" then the RunCommand acCmdRecordGoToNew.
|
| In the bottom half of the main form I have a FlexGrid ActiveX
| control which imitates an uneditable subform (datasheet) but
| the height of each row varies depending on content. It is this
| control that I want to update with the detail record just saved,
| whilst leaving the true subform available and ready to enter a
| brand new detail record. In fact the subform has no navigation
| buttons so that the user cannot access earlier detail records
| to edit (or even view) them.
|
| I haven't tested the DoCmd.GoToRecord variation yet to see if
| it also errors with a 2046.
|
| --
| Len
| __________________________________________________ ____
| remove nothing for valid email address.
| "Jeanette Cunningham" wrote in
message
| ...
| | The way I see it, you would requery the parent form to pick up any
new
| | information that has been added to the table/s the parent form is
based
| on
| | and then show them on the form.
| | If you are adding and editing information in the subform, I am not
| seeing
| | why there is a need to requery the parent form. Perhfaps there is
more
| to
| | this than shown in your post.
| |
| | To go to a new record in the subform, I would use code like this on
the
| save
| | button
| | --start of sample code
| | If Me.Dirty Then
| | Me.Dirty = False
| | End If
| |
| | DoCmd.GoToRecord , ,acNewRec
| | --end of sample code
| |
| |
| | Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
| |
| | ".Len B" wrote in message
| | ...
| | I have a form with a subform with no navigation buttons.
| | The subform has a cmdSave button to save the detail record.
| | In its click event I have
| | If Not Me.NewRecord Then RunCommand acCmdRecordGoToNew
| | Me.Parent.Requery
| |
| | Depending on the order of these two statements I get a
| | different problem.
| |
| | If I use the order shown, the RecordGoToNew works but it
| | is effectively undone by the requery. If I add another
| | RecordGoToNew line I get error 2046: The command or
| | action 'RecordGoToNew' isn't available now.
| |
| | If I switch order I receive the 2046 error.
| |
| | It seems that a requery prevents the GoToNew from working.
| |
| | So far I have avoided doing the requery at all but how do I
| | introduce it without creating a problem?
| |
| | --
| | Len
| | __________________________________________________ ____
| | remove nothing for valid email address.
| |
| |
| |
| |
|
|
|
|
|



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 01:43 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.