form uses query to open up appropriate form

M

Mark

I have a form/switchboard that allows users to enroll into
classes. Also, the form has a command button that opens
up a report for the user to see the classes they have
enrolled in. My problem is. I have a supervisor report
that I do not want regular employers to view. So, I
created a simple query that asks for the users ID and NT
Login name. in addition I have assigned each employee with
a number, which indicates what level of employee they
are. I would like the form to open without being able to
see the Access opening dialog box (it has the tables,
queries, forms, reports, etc.), so I have a blank form
with a command button that opens a query and based on the
employee number (title_number). and when the user clicks
on the query button and types in their ID/NT Login. if
they have a title_number greater than 1 the form with the
supervisor report command button opens up. anything else
opens up the form without the supervisor report button.
Below is my attempt at a query command button on the
opening/blank form, which I thought would open up the
appropriate form. I am not getting this to work. any
suggestions???



Private Sub OpensUserSwitchboard_Click()
On Error GoTo Err_OpensUserSwitchboard_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "queryOpensUserSwitchboard"
DoCmd.OpenQuery stDocName, acNormal, acEdit

If [Queries!queryOpensUserSwitchboard.Title_Number] >
1 Then
DoCmd.Close
stDocName = "UserSwitchboard1"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
DoCmd.Close
stDocName = "UserSwitchboard2"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If

Exit_OpensUserSwitchboard_Click:
Exit Sub

Err_OpensUserSwitchboard_Click:
MsgBox Err.Description
Resume Exit_OpensUserSwitchboard_Click

End Sub
 

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