Form Coding Issue in Upgrade from '97 to '03

D

dbain30

I had a database setup in Access 97. I had one button setup so that
when clicked it opened a form with a text field that contained the
following code. If the user typed "report" it would then open the
form "Download Control", anything else would just allow the user to
continue entering the password.

Private Sub Password_Admin_Enter()
If Password_Admin.Text = "report" Then
Me.Visible = False
DoCmd.OpenForm "Download Control"
Password_Admin.Text = ""
End If
Password_Admin.Text = ""
End Sub

The issue is that we have upgraded to Access 2003 and this code does
not work. If it helps, the form is titled "Admin Password" and the
text field is titled "Password Admin". The debugger seems focused on
the first line of the "if" statement but so far I cannot seem to find
anything to resolve the issue, although it seems like it would be an
easy fix.

Any assistance would be greatly appreciated!
 
A

Albert D. Kallal

I had a database setup in Access 97. I had one button setup so that
when clicked it opened a form with a text field that contained the
following code. If the user typed "report" it would then open the
form "Download Control", anything else would just allow the user to
continue entering the password.

Private Sub Password_Admin_Enter()
If Password_Admin.Text = "report" Then

I would try using:

If Password_Admin = "report" then

Me.Visible = False
DoCmd.OpenForm "Download Control"
Password_Admin = ""
End If

Password_Admin = ""

End Sub

You could also use Password_Admin.Value. While the text" property should
work, but is ONLY active when the form + control has focus. So, I would try
using .value (or leave .value it out as value is the default)
 
D

David W. Fenton

m:
If Password_Admin.Text = "report" Then

Really, you need to properly specify your objects. That should be:

If Me!Password_Admin = "report" Then

OR:

If Me.Password_Admin = "report" Then

(I prefer the !)

It's really bad practice to not specify the parent object of a
control your form.
 
M

Mike Painter

dbain30 said:
If Password_Admin.Text
<snip>
text field is titled "Password Admin".
As mentioned you should be using "Me" but
Password_Admin <> [Password Admin]
 

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