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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|