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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Label not defined 4

Status
Not open for further replies.

Russ1005

Programmer
Dec 13, 2004
96
US
I'm getting the following error:

The expression On Open you entered as the event property setting produced the following error: Label not defined.

Any idea what's causing this?
Thanks,
Russ


Private Sub Form_Open(Cancel As Integer)

Application.SetOption "ShowWindowsInTaskBar", False

varusername = fOSUserName()

VendorClaims.Visible = False

gstrUserRole = DLookup("[csr_role]", "customer_claims_csr", "[csr_login] = '" & varusername & "'")
If gstrUserRole <> "Claims Administrator" And gstrUserRole <> "Developer" Then
Disposition.Enabled = False
Admin.Enabled = False
Else
Disposition.Enabled = True
Reports.Enabled = True
Admin.Enabled = True
End If

Debug.Print "gstrUserRole", gstrUserRole
Debug.Print "varusername:", varusername
Debug.Print Now
End Sub
 
Nothing is highlighted when the error occurs. It is the open event of the main form.
 
I put a stop statement at the top of the function but it hits the error before the stop statement executes.
 
I'm not an access expert, but... does the form_open event actually have a cancel parameter?

In vb, there is a Form_Load that does not have any parameters. I suggest you remove the Cancel As Integer from the parameter list and try it again.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
I commented out the code and removed the cancel as integer parm but that produced the following error:

Procedure declaration does not math description of event or procedure having the same name.
 
try removing the quotes around the field names. I don't know if they are needed. It might be reading the field names as labels because of that.

_______________
conceptNEXT.com
[cN]
 
Someone suggested moving the code to the On Load event. That got rid of the error but I don't understand why.

Thanks for your help.
 
Access Help Topic said:
Form and control events occur as you move between records in the form and change data. For example, when you first open a form, the following sequence of events occurs:

Open (form) --> Load (form) --> Resize (form) --> Activate (form) --> Current (form) --> Enter (control) --> GotFocus (control)

Trying to do something with a control on a form before the control has loaded results in Access not being able to recognise it, because at that stage the control doesn't exist in memory and therefore can't be manipulated.

Check out the on-line Help topic Order of events for database objects for more information on event orders.

HTH
Lightning

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top