code not working

O

octet

Iam trying to run this code but i get an error after CASE 1 and then after
case 2 i am new to programing can anyone help with this?

Thanks Octet

Option Compare Database
Option Explicit

Private Sub grpEmployees_AfterUpdate()
Dim strSQL As String

'Open rptEmployeeList or rptemployeesByDept
' base on critreia enterd int form by user

strSQL = "Teminated =" & chkTerm

Select Case grpEmployees
Case 1
DoCmd.OpenReport "rptEmployeesList", acViewPreview, , strSQL
Case 2
DoCmd.OpenReport "rptEmployeesByDept", acViewPreview, , strSQL
End Select
grpEmployees = Null

End Sub
 
J

Jack Leach

Select Case grpEmployees
Case 1
DoCmd.OpenReport "rptEmployeesList", acViewPreview, , strSQL
Case 2
DoCmd.OpenReport "rptEmployeesByDept", acViewPreview, , strSQL
End Select
grpEmployees = Null

if grpEmployees is a control, you need to use the Me keyword...

Select Case Me.grpEmployees
Case 1
DoCmd.OpenReport...
Case 2
DoCmd.OpenReport
End Select


Me.grpEmployees should read the value, but that is actually the way to refer
to the control itself as an object rather than the data in it. To be
concise, you may want to use Me.grpEmployees.Value

hth

--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
 
O

octet

Thanks that worked

Jack Leach said:
if grpEmployees is a control, you need to use the Me keyword...

Select Case Me.grpEmployees
Case 1
DoCmd.OpenReport...
Case 2
DoCmd.OpenReport
End Select


Me.grpEmployees should read the value, but that is actually the way to refer
to the control itself as an object rather than the data in it. To be
concise, you may want to use Me.grpEmployees.Value

hth

--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
 

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