473,387 Members | 1,486 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Simple Syntax Snafu and Error 2489?

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
4 5249
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Mtk | last post by:
Hi! Why does the following, simple, example produce such errors? I know it has to do with the two header files including each other and (moreover) the usage of the classes One and Two in the...
7
by: .Net Sports | last post by:
Before processing my data in a datagrid, I need to parse the day of the week (which will be my 'rqsday' variable) from a string that comes over on a querystring: string rqs =...
4
by: Robert Dobson | last post by:
I've run into a rather perplexing problem and unfortunately nobody has yet been able to help me resolve it. I have built an application that supports both English and Spanish text. When I...
0
by: pshipway9[snipATsnip]yahoo.com | last post by:
I can't get vb.net to create a new Excel.Application object. MS Development Environment 7.1.3088 Net Framework 1.1 Office 2003 I understand the DIM exl as new Excel.Application stuff. I think...
73
by: Claudio Grondi | last post by:
In the process of learning about some deeper details of Python I am curious if it is possible to write a 'prefix' code assigning to a and b something special, so, that Python gets trapped in an...
15
by: gjoneshtfc | last post by:
Hello, I have a simple problem that I just cannot get my head around! I currently have the following line in my ASP recordset: Recordset1.Source = "SELECT * FROM MainTable ORDER BY Price ASC"...
8
by: Bern McCarty | last post by:
I have a simple ref class in its own namespace that needs to coexist with a legacy typedef alias for "unsigned int" in the global namespace that has the identifier as itself. Everything compiles...
3
by: Deano | last post by:
Hi, I just want to add a text column to a table in my code. I can't find a simple example of this. dbs.Execute ("ALTER tblCCOccurrences ADD COLUMN Year1 Text;"). This gives me; Syntax...
6
kenobewan
by: kenobewan | last post by:
Congratulations! You are one of the few who realise that over 80% of errors are simple and easy to fix. It is important to realise this as it can save a lot of time. Time that could be wasted making...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.