Object required???

G

google3luo359

Hello,

I'm getting an "Object required" error message with no other clues as
to what or where the on object needed is.

The error is related to this new code I put in when a button is clicked
on a form:

If Not IsNull(Me!cboStudNum) Then
If Me!txtPassword = Me!cboStudNum.Column(1) Then

If Me!cboStudNum.Column(2) = 9 Then
DoCmd.OpenForm "fmAEP"
fmAEP.tabAEP.Pages(0).SetFocus
End If

If Me!cboStudNum.Column(2) = 10 Then
DoCmd.OpenForm "fmAEP"
fmAEP.tabAEP.Pages(1).SetFocus
End If .....

Is there anything obvious here that accounts for this error message?

TIA Ric
 
K

Ken Snell \(MVP\)

Yep, it's obvious ....

You're trying to use the variable fmAEP as a form object.
Here:
fmAEP.tabAEP.Pages(0).SetFocus

and here:
fmAEP.tabAEP.Pages(1).SetFocus

.. But you never instantiated that object so that you can use it. May I
suggest not using a form object, and just rewrite the code steps this way:

Forms("fmAEP").tabAEP.Pages(0).SetFocus

and here:
Forms("fmAEP").tabAEP.Pages(1).SetFocus
 
G

google3luo359

Ken said:
. But you never instantiated that object so that you can use it. May I
suggest not using a form object, and just rewrite the code steps this way:

Forms("fmAEP").tabAEP.Pages(0).SetFocus

and here:
Forms("fmAEP").tabAEP.Pages(1).SetFocus


Thanks Ken.
Before receiving your reply I went back to study some of my older code
and tried out the following:

If Me!cboStudNum.Column(2) = "9" Then
Forms![fmAEP]!tabAEP.Pages(0).SetFocus
End If

If Me!cboStudNum.Column(2) = "10" Then
Forms![fmAEP]!tabAEP.Pages(1).SetFocus

which worked and which is essentially the same as what you suggested.
Thanks very much!

Ric
 
K

Ken Snell \(MVP\)

Yep, those syntaces will work well too. Glad you found your solution! You're
welcome.

--

Ken Snell
<MS ACCESS MVP>

. But you never instantiated that object so that you can use it. May I
suggest not using a form object, and just rewrite the code steps this
way:

Forms("fmAEP").tabAEP.Pages(0).SetFocus

and here:
Forms("fmAEP").tabAEP.Pages(1).SetFocus


Thanks Ken.
Before receiving your reply I went back to study some of my older code
and tried out the following:

If Me!cboStudNum.Column(2) = "9" Then
Forms![fmAEP]!tabAEP.Pages(0).SetFocus
End If

If Me!cboStudNum.Column(2) = "10" Then
Forms![fmAEP]!tabAEP.Pages(1).SetFocus

which worked and which is essentially the same as what you suggested.
Thanks very much!

Ric
 

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

Top