Requerying a form after changes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form used to change the cycle into which a customer falls. After
changing the cycle., e.g., from 1 to 5, I want a button on the form to run
the query underlying the form to immediately resort the record and show it in
the new cycle.

I've tried requerying the control, but I receive an error 2109 "There is no
field named "1" (or whatever number I type in the control) in this record. I
also found a suggestion in the newsgroups to set the focus to the control
first, but received the same error.

Me![txtCycle].SetFocus
DoCmd.Requery ([txtCycle])

Any suggestions for achieving the goal of an "instant" re-sort of the records?
 
Susan L said:
I have a form used to change the cycle into which a customer falls. After
changing the cycle., e.g., from 1 to 5, I want a button on the form to run
the query underlying the form to immediately resort the record and show it in
the new cycle.

I've tried requerying the control, but I receive an error 2109 "There is no
field named "1" (or whatever number I type in the control) in this record. I
also found a suggestion in the newsgroups to set the focus to the control
first, but received the same error.

Me![txtCycle].SetFocus
DoCmd.Requery ([txtCycle])

Any suggestions for achieving the goal of an "instant" re-sort of the records?

You need to requery the form, not the control. That will of course cause you to
lose the record position you are currently at. Is that a problem? Is this a
continuous form? If not I fail to see why you would want to re-sort.
 
Yes, this is a continuous form and it's important to the use of the form not
to keep the record position, but to resort so all customers in each cycle are
contiguous to each other.

I've tried the following code on the "Sort" button i had created and also on
the AfterUpdate event of the form. Am getting errors for each. My syntax (or
placement of the code) is probably incorrect. here is the code:

Private Sub Form_AfterUpdate()
DoCmd.Requery Forms!frmChangeCycle
End Sub
Would appreciate feedback. Thanks, Rick.

--
susan


Rick Brandt said:
Susan L said:
I have a form used to change the cycle into which a customer falls. After
changing the cycle., e.g., from 1 to 5, I want a button on the form to run
the query underlying the form to immediately resort the record and show it in
the new cycle.

I've tried requerying the control, but I receive an error 2109 "There is no
field named "1" (or whatever number I type in the control) in this record. I
also found a suggestion in the newsgroups to set the focus to the control
first, but received the same error.

Me![txtCycle].SetFocus
DoCmd.Requery ([txtCycle])

Any suggestions for achieving the goal of an "instant" re-sort of the records?

You need to requery the form, not the control. That will of course cause you to
lose the record position you are currently at. Is that a problem? Is this a
continuous form? If not I fail to see why you would want to re-sort.
 
Susan L said:
Yes, this is a continuous form and it's important to the use of the form not
to keep the record position, but to resort so all customers in each cycle are
contiguous to each other.

I've tried the following code on the "Sort" button i had created and also on
the AfterUpdate event of the form. Am getting errors for each. My syntax (or
placement of the code) is probably incorrect. here is the code:

Private Sub Form_AfterUpdate()
DoCmd.Requery Forms!frmChangeCycle
End Sub
Would appreciate feedback. Thanks, Rick.

All you need is...

Me.Requery
 
Face is a bit red! What a simple answer, which, of course works perfectly.
Thanks for your patience and help.
 
I have a similar problem, however I would need to go to the next record and
not start at the first record again.

Is this possible?

Thanks in advance

Rick Brandt said:
Susan L said:
I have a form used to change the cycle into which a customer falls. After
changing the cycle., e.g., from 1 to 5, I want a button on the form to run
the query underlying the form to immediately resort the record and show it in
the new cycle.

I've tried requerying the control, but I receive an error 2109 "There is no
field named "1" (or whatever number I type in the control) in this record. I
also found a suggestion in the newsgroups to set the focus to the control
first, but received the same error.

Me![txtCycle].SetFocus
DoCmd.Requery ([txtCycle])

Any suggestions for achieving the goal of an "instant" re-sort of the records?

You need to requery the form, not the control. That will of course cause you to
lose the record position you are currently at. Is that a problem? Is this a
continuous form? If not I fail to see why you would want to re-sort.
 

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

Back
Top