HELP!!! Activescreen control (1 Viewer)

gar348

Registered User.
Local time
Today, 06:55
Joined
Jan 24, 2017
Messages
17
Hello.......

Need some help with a new problem that has just come up as my database is about to go live.....

form design is

Main form

Tab control

Sub form in tab control

***********

On tab 1 when a field is changed there is a very basic me1.[xxx]=me2.[xx].

Me 2 is in tab 1 and me 1 (field being updated is in tab 2)

The update works fine but when the user exits the form they are getting the error

ERROR ! The expression you entered requires the control to be in the active window.....

No error numbers.....

I think on the exit command of the form I just need to browse to the filed that was updated to make that "active" then exit....But cant figure the code out for it......
 

RuralGuy

AWF VIP
Local time
Yesterday, 23:55
Joined
Jul 2, 2005
Messages
13,826
In what event do you execute the:
"On tab 1 when a field is changed there is a very basic me1.[xxx]=me2.[xx]."?
 

gar348

Registered User.
Local time
Today, 06:55
Joined
Jan 24, 2017
Messages
17
it's on the lost focus event of the field
 

RuralGuy

AWF VIP
Local time
Yesterday, 23:55
Joined
Jul 2, 2005
Messages
13,826
Try putting your code in the AfterUpdate event of the control instead and see what happens.
 

gar348

Registered User.
Local time
Today, 06:55
Joined
Jan 24, 2017
Messages
17
Yeah the same thing. . .

think of the return to menu button I have I need to put something to mate the tab active. .. .
 

RuralGuy

AWF VIP
Local time
Yesterday, 23:55
Joined
Jul 2, 2005
Messages
13,826
Something else is going on here. Each control on all of the tabs of a tab control have unique names. You can reference any control from any tab without needing to change the focus. What version of Access are you using and what OS?
 

RuralGuy

AWF VIP
Local time
Yesterday, 23:55
Joined
Jul 2, 2005
Messages
13,826
What code do you have in the "return to menu button I have"?
 

gar348

Registered User.
Local time
Today, 06:55
Joined
Jan 24, 2017
Messages
17
using access 2010 . .

return to menu is just close main form open switchboard
 

RuralGuy

AWF VIP
Local time
Yesterday, 23:55
Joined
Jul 2, 2005
Messages
13,826
At this point I don't think we know exactly where the error is being raised. Are the controls on the tab form bound to fields in the RecordSource of the MainForm? Where is the "Return to Menu" button of which you speak? Is it on the same form as the TabControl?
 

gar348

Registered User.
Local time
Today, 06:55
Joined
Jan 24, 2017
Messages
17
hello. . Yes all the fields are bound and in the data source of the main form. .

the return to menu button is in the footer of the main form. . .

What's really strange is if you change the value. . .navigate to the changed field then hit the exit button you don't get an error
 

RuralGuy

AWF VIP
Local time
Yesterday, 23:55
Joined
Jul 2, 2005
Messages
13,826
Let's look at this code again:
"On tab 1 when a field is changed there is a very basic me1.[xxx]=me2.[xx]."?

The syntax seems wrong. It should be: Me.TabOneControlName = Me.TabTwoControlName.

Does that make sense? You simply ignore the fact that the controls are on a TabControl.
 

gar348

Registered User.
Local time
Today, 06:55
Joined
Jan 24, 2017
Messages
17
Hello Sorry for the slow reply - had to leave in a hurry last night....

So the actual control is written

Forms!FrmNewcastleQRCJobs!PMUEST2![Sell Price] = [Order Value]
 

gar348

Registered User.
Local time
Today, 06:55
Joined
Jan 24, 2017
Messages
17
Come up with a short term fix - since the form was updating just added the command

DoCmd.SetWarnings False

to the exit of the form...

DoCmd.SetWarnings False
DoCmd.OpenForm "TEST FORM 1", acNormal
DoCmd.Close acForm, "FrmNewcastleQRCJObs", acSavePrompt
 

RuralGuy

AWF VIP
Local time
Yesterday, 23:55
Joined
Jul 2, 2005
Messages
13,826
Hello Sorry for the slow reply - had to leave in a hurry last night....

So the actual control is written

Forms!FrmNewcastleQRCJobs!PMUEST2![Sell Price] = [Order Value]
Try changing this line to:
Me.[Sell Price] = Me.[Order Value]
...and leave the Warnings turned on.
 

gar348

Registered User.
Local time
Today, 06:55
Joined
Jan 24, 2017
Messages
17
That's not possible as the control [sell price] is in a diff subform
 

RuralGuy

AWF VIP
Local time
Yesterday, 23:55
Joined
Jul 2, 2005
Messages
13,826
I don't remember you mentioning a SubForm before. I thought it was just controls on a different tab of a TabControl.
 

RuralGuy

AWF VIP
Local time
Yesterday, 23:55
Joined
Jul 2, 2005
Messages
13,826
Okay, your first post does mention a SubForm. Try this:

Me.Parent.PMUEST2.FORM.[Sell Price] = Me.[Order Value]

...with warnings enabled.
 

RuralGuy

AWF VIP
Local time
Yesterday, 23:55
Joined
Jul 2, 2005
Messages
13,826
If the [Order Value] control in not on a SubForm then try:

PMUST2.FORM.[Sell Price] = Me.[Order Value]
 

gar348

Registered User.
Local time
Today, 06:55
Joined
Jan 24, 2017
Messages
17
Hello

Its updating the field but still coming up with the attached error
 

Attachments

  • 2017-02-16 14_32_54-Newcastle Repair Database.png
    2017-02-16 14_32_54-Newcastle Repair Database.png
    7.8 KB · Views: 64

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 00:55
Joined
Feb 28, 2001
Messages
27,321
What's really strange is if you change the value. . .navigate to the changed field then hit the exit button you don't get an error

What events are associated with the changed field? GotFocus or LostFocus, perhaps? And if so, what do the field's events do? It is possible that this is occurring because of something you are doing in those events.

For instance, if the event code contains a .SetFocus or an .Enable=True (or False, for that matter), you are changing the focus of something and that DOES interact with the window in question. You say that it fails when you exit from another tab but works cleanly when you exit from the tab with the miscreant control. Setting a value just cannot do that - but setting a display-related property CAN throw active-control errors in complex cases.
 
Last edited:

Users who are viewing this thread

Top Bottom