Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

On_Click of Button Goes Straight to Sub in Form

Status
Not open for further replies.

jodo

Programmer
Feb 18, 2002
42
0
0
US
Using Access 2000, Windows 2000
I have created a form with 5 buttons on it to open forms. Four currently work. When I added the 5th button today to open the form (just like all the rest) it goes straight into the ON_ENTER code on the form.

When it gets to this point in main code that calls the form.....
DoCmd.OpenForm stDocName, , , stLinkCriteria

....it immediately enters the following sub and it causes an error because it's recognizing the Main calling form as active and not the actual form that is called. The Main calling form ActiveControl is a button and it throws and error when it reaches the ctrlTemp.text because "OBJECT DOES NOT SUPPORT THIS PROPERTY OR METHOD". There are numerous controls on the called form and the idea is when the user enters the control it kicks off this code; therefore, gathering all of the control data and passing it to another function. This is only a sample of one of the controls on my form. The weird thing is that if there is only 1 ON_ENTER sub, it works just fine, but more than one throws the error.


Private Sub NET_MWH_Enter()
Dim ctrlTemp As Control
Dim frm As Form
''FOR SOME REASON, IT'S NOT SEEING THE REPORT(FORM) AS THE ACTIVE FORM, BUT THE ADMINISTRATOR FORM
Set ctrlTemp = Screen.ActiveControl
Set frm = Screen.ActiveForm
Call Enter(Me.NET_MWH_TLQ.value, ctrlTemp.Text, ctrlTemp.Properties(1), "LAKDBA_JLK_LOAD", frm)
End Sub


--The ctrlTemp.Text is the value in the control.
--The ctrlTemp.Properties(1) is the first property for that control which happens to be the name of the control.
--"LAKDBA_JLK_LOAD" is my table.
--frm is the active form

I've tried hard-coding in the ctrlTemp.Text and ctrlTemp.Properties(1), but it threw and error for the frm argument.

NOTE: This is currently working of 4 other forms. There is no reason for it not to work; however, we all know "MURPHY".

If someone knows why this is happening, any help would be greatly appreciated. Thanks in advance.

jodo
[sunshine]
LUCK - WHERE PREPARATION MEETS OPPORTUNITY!!
 
The weird thing is that if there is only 1 ON_ENTER sub, it works just fine, but more than one throws the error

Well there is a clue

there MUST only be one
Private Sub Form_On_Enter()
line in any module


Also
Me.NET_MWH_TLQ.value is the same as NET_MWH_TLQ
ctrlTemp.Text is the same as ctrlTemp
ctrlTemp.Properties(1) is the same as ctrlTemp.Name

so why make things more complex than they need to be.
( Unless you are deliberatly using .Value to cause the NET_MWH_TLQ.AfterUpdate event to fire when this code runs. )


If the above doesn't help post the code for Enter( .. ... )
And post it in BLACK please - the red is virtually unreadable.






G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
This isn't a module; however, it passes the values to a module. The ON_ENTER's refer to bound controls in a record that are on the form.

**And Yes, Me.NET_MWH_TLQ.value is the same as NET_MWH_TLQ, thanks for that.
**ctrlTemp.Text is the same as ctrlTemp
**ctrlTemp.Properties(1) is the same as ctrlTemp.Name, I didn't know that, THANKS!

The intelli-sense doesn't provide the .name property for controls, so I didn't know that it existed, but I do now.

I'm new to working with passing controls, so I'm learning.

I figured out the problem too. I set the TAB STOP to 'NO' in the properties for the controls on the form. Apparantly, it was stopping on a bound control when it loaded, thus forcing it into the ON_ENTER.

Thanks for your help. What matters is, I did learn something new today.

jodo
[sunshine]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top