By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,662 Members | 1,141 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,662 IT Pros & Developers. It's quick & easy.

Simple Syntax Snafu and Error 2489?

P: n/a
I have a Main form (named FRM_Main in the Forms Window) with a Subform
(named FRM_User_Search in the Forms window, form_User_Search on
Forms_Main).

FRM_User_Search has a combo-box (cboSort) the user will hopefully be
able to use to change the sort order of the records on the same form.

Here's the code for the "OnChange" event, minus the
DoCmd.Repaint.Object Line:

*************************************************
Private Sub cboSort_Change()

If cboSort.Value <> "" Then
'Re-sort the values based on the selection
Me.OrderBy = cboSort.Value

'<<<< DoCmd.Repaint.Object Line Goes Here >>>>

End If

End Sub
*************************************************

I can't get the DoCmd.Repaint.Object Line working - Access tells me
the form is not open.

I've tried many variations of ways to refer to the form
FRM_User_Search, including;

DoCmd.RepaintObject acForm, "FRM_User_Search"
DoCmd.RepaintObject acForm, "form_User_Search"
DoCmd.RepaintObject acForm,
Forms![FRM_Main]![form_User_Search]

Access continues to tell me the form is not open (while it sits there,
mockingly, staring at me).

In another DB, I use the line

DoCmd.RepaintObject acForm, "frm_User_Search"

where the form is the only form open, and it works like a charm.

I have seen various other postings on this subject (Error 2489)
but have been unable to glean a solution that will work in this case.
I tried opening the form programmatically before the Repaint, but that
opens another copy.

Can anyone offer a suggestion?

I must admit, one area I'm always confused about is when to use the
name of a subForm as it appears in the Forms window and when to use
the name you've given it on the main form. Someone once told me you
should always make them different, although I'm not sure a) why or b)
if I'm needlessly poking myself in the eye.

Since I've tried it both ways here, I surmise that's not the issue,
but I'm still curious about what others say about the "2 names"
method.

Thanks.

Patrick Arkins
Nov 13 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On 5 Oct 2004 06:29:31 -0700, Patrick Arkins wrote:
I can't get the DoCmd.Repaint.Object Line working - Access tells me
the form is not open.


Try something like this:
If Me.cboSort.Value <> "" Then
'Re-sort the values based on the selection
Me.Parent.Form.OrderBy = cboSort.Value
'Instantly this has to be made
Me.Parent.Form.OrderByOn = True
'I'ld prefer
'Me.Parent.Form.Refresh
'<<<< DoCmd.Repaint.Object Line Goes Here >>>>
DoCmd.RepaintObject acForm, Me.Parent.Form.Name
End If

Hth

Heiko Ulf

Nov 13 '05 #2

P: n/a
maybe try me.refresh instead?

What is cboSort sorting the form by? I'm pretty sure you can only
sort (order) by fieldnames in a table (the table the form is bound to)
and not by values in a particular field, which sounds like what you
were trying to do. Were you trying to bring up a particular record
for that user instead of sorting by (order by) it?

As for naming the subform and the subform control two different things
- you should never have two different objects named the same thing -
even if the computer can figure it out, it is easier for the human to
differentiate with different names. I always name my subforms
sfrmFormName, and put sfrmControlFormName (or sfrmCtrlFormName) as the
subform control, so I can tell which is which.

me*****@butter.toast.net (Patrick Arkins) wrote in message news:<ae**************************@posting.google. com>...
I have a Main form (named FRM_Main in the Forms Window) with a Subform
(named FRM_User_Search in the Forms window, form_User_Search on
Forms_Main).

FRM_User_Search has a combo-box (cboSort) the user will hopefully be
able to use to change the sort order of the records on the same form.

Here's the code for the "OnChange" event, minus the
DoCmd.Repaint.Object Line:

*************************************************
Private Sub cboSort_Change()

If cboSort.Value <> "" Then
'Re-sort the values based on the selection
Me.OrderBy = cboSort.Value

'<<<< DoCmd.Repaint.Object Line Goes Here >>>>

End If

End Sub
*************************************************

I can't get the DoCmd.Repaint.Object Line working - Access tells me
the form is not open.

I've tried many variations of ways to refer to the form
FRM_User_Search, including;

DoCmd.RepaintObject acForm, "FRM_User_Search"
DoCmd.RepaintObject acForm, "form_User_Search"
DoCmd.RepaintObject acForm,
Forms![FRM_Main]![form_User_Search]

Access continues to tell me the form is not open (while it sits there,
mockingly, staring at me).

In another DB, I use the line

DoCmd.RepaintObject acForm, "frm_User_Search"

where the form is the only form open, and it works like a charm.

I have seen various other postings on this subject (Error 2489)
but have been unable to glean a solution that will work in this case.
I tried opening the form programmatically before the Repaint, but that
opens another copy.

Can anyone offer a suggestion?

I must admit, one area I'm always confused about is when to use the
name of a subForm as it appears in the Forms window and when to use
the name you've given it on the main form. Someone once told me you
should always make them different, although I'm not sure a) why or b)
if I'm needlessly poking myself in the eye.

Since I've tried it both ways here, I surmise that's not the issue,
but I'm still curious about what others say about the "2 names"
method.

Thanks.

Patrick Arkins

Nov 13 '05 #3

P: n/a
Heiko -

Me.Refresh works dandy, thanks.

Patrick

Heiko Ulf <sp******************@yahoo.de> wrote in message news:<kv********************************@4ax.com>. ..
On 5 Oct 2004 06:29:31 -0700, Patrick Arkins wrote:
I can't get the DoCmd.Repaint.Object Line working - Access tells me
the form is not open.


Try something like this:
If Me.cboSort.Value <> "" Then
'Re-sort the values based on the selection
Me.Parent.Form.OrderBy = cboSort.Value
'Instantly this has to be made
Me.Parent.Form.OrderByOn = True
'I'ld prefer
'Me.Parent.Form.Refresh
'<<<< DoCmd.Repaint.Object Line Goes Here >>>>
DoCmd.RepaintObject acForm, Me.Parent.Form.Name
End If

Hth

Heiko Ulf

Nov 13 '05 #4

P: n/a
Thanks for your reply.

Me.Refresh seems to work like a charm!

And thanks for the explanation. I still get confused as to when to
use which "name" in code, but I suppose over time it will either
become clear or I will amass enough example to refer back to.

Thanks again.

Patrick

us*******@hotmail.com (user_5701) wrote in message news:<f1**************************@posting.google. com>...
maybe try me.refresh instead?

What is cboSort sorting the form by? I'm pretty sure you can only
sort (order) by fieldnames in a table (the table the form is bound to)
and not by values in a particular field, which sounds like what you
were trying to do. Were you trying to bring up a particular record
for that user instead of sorting by (order by) it?

As for naming the subform and the subform control two different things
- you should never have two different objects named the same thing -
even if the computer can figure it out, it is easier for the human to
differentiate with different names. I always name my subforms
sfrmFormName, and put sfrmControlFormName (or sfrmCtrlFormName) as the
subform control, so I can tell which is which.

me*****@butter.toast.net (Patrick Arkins) wrote in message news:<ae**************************@posting.google. com>...
I have a Main form (named FRM_Main in the Forms Window) with a Subform
(named FRM_User_Search in the Forms window, form_User_Search on
Forms_Main).

FRM_User_Search has a combo-box (cboSort) the user will hopefully be
able to use to change the sort order of the records on the same form.

Here's the code for the "OnChange" event, minus the
DoCmd.Repaint.Object Line:

*************************************************
Private Sub cboSort_Change()

If cboSort.Value <> "" Then
'Re-sort the values based on the selection
Me.OrderBy = cboSort.Value

'<<<< DoCmd.Repaint.Object Line Goes Here >>>>

End If

End Sub
*************************************************

I can't get the DoCmd.Repaint.Object Line working - Access tells me
the form is not open.

I've tried many variations of ways to refer to the form
FRM_User_Search, including;

DoCmd.RepaintObject acForm, "FRM_User_Search"
DoCmd.RepaintObject acForm, "form_User_Search"
DoCmd.RepaintObject acForm,
Forms![FRM_Main]![form_User_Search]

Access continues to tell me the form is not open (while it sits there,
mockingly, staring at me).

In another DB, I use the line

DoCmd.RepaintObject acForm, "frm_User_Search"

where the form is the only form open, and it works like a charm.

I have seen various other postings on this subject (Error 2489)
but have been unable to glean a solution that will work in this case.
I tried opening the form programmatically before the Repaint, but that
opens another copy.

Can anyone offer a suggestion?

I must admit, one area I'm always confused about is when to use the
name of a subForm as it appears in the Forms window and when to use
the name you've given it on the main form. Someone once told me you
should always make them different, although I'm not sure a) why or b)
if I'm needlessly poking myself in the eye.

Since I've tried it both ways here, I surmise that's not the issue,
but I'm still curious about what others say about the "2 names"
method.

Thanks.

Patrick Arkins

Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.