HELP! I have switchboard that in which I wrote the following. The first subform worked before I added the second. I get a complie error "expected end sub" and the line Private sub form_open (cancel as integer) line. I don't know SQL so if someone could tell me what I am missing. Thanks
Private Sub Form_Load()
DoCmd.RunSQL "DELETE GL8_BudgetAndHistory.* FROM GL8_BudgetAndHistory;"
DoCmd.RunSQL "INSERT INTO GL8_BudgetAndHistory SELECT GL8_BudgetAndHistory1.* FROM GL8_BudgetAndHistory1;"
End Sub
Private Sub Form_Open(Cancel As Integer)
Public Function OnStartup()
Dim rst As dao.Recordset
Dim strSQL As String
strSQL = "slect fldDepartment, fldPermission FROM table westek users" & ";"
'Open a recordset of all users
Set rst = CurrentDb.OpenRecordset(strSQL)
'if they are not in the list then see if they are an admin
If Not rst.EOF Then
If rst!fldPermission = "Admin" Then
DoCmd.OpenForm "Switchboard" 'Open the main switchboard if this person is the admin
Else
'If they aren't an admin, get the department and open the corresponding form
Select Case rst!fldDepartment
Case "Sales"
DoCmd.OpenForm "frmSales" 'This is where you open the form that corresponds to the Sales department
Case "Materials"
DoCmd.OpenForm "frmMaterials" 'This is where you open the form that corresponds to the Materials department
Case "Fiber"
DoCmd.OpenForm "frmFiber" 'This is where you open the form that corresponds to the Fiber department
Case "HR"
DoCmd.OpenForm "frmHR" 'This is where you open the form that corresponds to the HR department
Case "Facilities"
DoCmd.OpenForm "frmFacilities" 'This is where you open the form that corresponds to the Facilities department
Case "Planning"
DoCmd.OpenForm "frmPlanning" 'This is where you open the form that corresponds to the Planning department
Case "MIS"
DoCmd.OpenForm "frmMIS" 'This is where you open the form that corresponds to the MIS department
Case "Corporate"
DoCmd.OpenForm "frmCorporate" 'This is where you open the form that corresponds to the Corporate department
Case "QC"
DoCmd.oepnform "frmQC" 'This is where you open the form that corresponds to the QC department
Case "Engineering"
DoCmd.OpenForm "frmEngineering" 'This is there you open the form that correspondends to the Engineering department
Case "Accounting"
DoCmd.OpenForm "frmMarketing" 'This is where you open the form that corresponds to the Marketing department
Case "Production"
DoCmd.OpenForm "frmProduction" 'This is where you open the form that corresponds to the Production department
End Select
End If
Else
'This person is not in the list of valid users, so tell them and quit the application
MsgBox "You are not a valid user of this application.", vbCritical, "Invalid User"
Application.Quit
End If
'Close and kill the recordset
rst.Close
Set rst = Nothing
End Function
Private Sub Form_Load()
DoCmd.RunSQL "DELETE GL8_BudgetAndHistory.* FROM GL8_BudgetAndHistory;"
DoCmd.RunSQL "INSERT INTO GL8_BudgetAndHistory SELECT GL8_BudgetAndHistory1.* FROM GL8_BudgetAndHistory1;"
End Sub
Private Sub Form_Open(Cancel As Integer)
Public Function OnStartup()
Dim rst As dao.Recordset
Dim strSQL As String
strSQL = "slect fldDepartment, fldPermission FROM table westek users" & ";"
'Open a recordset of all users
Set rst = CurrentDb.OpenRecordset(strSQL)
'if they are not in the list then see if they are an admin
If Not rst.EOF Then
If rst!fldPermission = "Admin" Then
DoCmd.OpenForm "Switchboard" 'Open the main switchboard if this person is the admin
Else
'If they aren't an admin, get the department and open the corresponding form
Select Case rst!fldDepartment
Case "Sales"
DoCmd.OpenForm "frmSales" 'This is where you open the form that corresponds to the Sales department
Case "Materials"
DoCmd.OpenForm "frmMaterials" 'This is where you open the form that corresponds to the Materials department
Case "Fiber"
DoCmd.OpenForm "frmFiber" 'This is where you open the form that corresponds to the Fiber department
Case "HR"
DoCmd.OpenForm "frmHR" 'This is where you open the form that corresponds to the HR department
Case "Facilities"
DoCmd.OpenForm "frmFacilities" 'This is where you open the form that corresponds to the Facilities department
Case "Planning"
DoCmd.OpenForm "frmPlanning" 'This is where you open the form that corresponds to the Planning department
Case "MIS"
DoCmd.OpenForm "frmMIS" 'This is where you open the form that corresponds to the MIS department
Case "Corporate"
DoCmd.OpenForm "frmCorporate" 'This is where you open the form that corresponds to the Corporate department
Case "QC"
DoCmd.oepnform "frmQC" 'This is where you open the form that corresponds to the QC department
Case "Engineering"
DoCmd.OpenForm "frmEngineering" 'This is there you open the form that correspondends to the Engineering department
Case "Accounting"
DoCmd.OpenForm "frmMarketing" 'This is where you open the form that corresponds to the Marketing department
Case "Production"
DoCmd.OpenForm "frmProduction" 'This is where you open the form that corresponds to the Production department
End Select
End If
Else
'This person is not in the list of valid users, so tell them and quit the application
MsgBox "You are not a valid user of this application.", vbCritical, "Invalid User"
Application.Quit
End If
'Close and kill the recordset
rst.Close
Set rst = Nothing
End Function