ms access convert macro to vba

Dear Expert,

My combo box in a form having macro to run after update (i.e. after selecting the value) and it was running perfectly. Unfortunately, while converting some other code from  macro to vba this macro also was converted to vba. to which after converting this combo box after update is generating an error (TempVars can only store data. They cannot store object).

Could you please help to make this code

The code in vba as follow:

Private Sub cboReports_AfterUpdate()
On Error GoTo cboReports_AfterUpdate_Err

    ' _AXL:<?xml version="1.0" encoding="UTF-16" standalone="no"?>
    ' <UserInterfaceMacro For="cmdEmployeeList" Event="OnClick" xmlns="http://schemas.microsoft.com/office/accessservices/2009/11/application" xmlns:a="http://schemas.microsoft.com/office/accessser
    ' _AXL:vices/2009/11/forms"><Statements><Action Name="OpenForm"><Argument Name="FormName">frm01_Project List</Argument><Argument Name="View">Datasheet</Argument></Action></Statements></UserInterfaceMacro>
    If (IsNull(Screen.ActiveControl)) Then
        Exit Sub
    End If
    TempVars.Add "ReportToOpen", Screen.ActiveControl
    If (CurrentProject.IsTrusted) Then
        Screen.ActiveControl = Null
    End If
    DoCmd.OpenReport TempVars!ReportToOpen, acViewPreview, "", "", acNormal
    TempVars.Remove "ReportToOpen"


cboReports_AfterUpdate_Exit:
    Exit Sub

cboReports_AfterUpdate_Err:
    MsgBox Error$
    Resume cboReports_AfterUpdate_Exit

End Sub

Open in new window

TAB-000Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MacroShadowCommented:
Is this what you want, to open the report selected in the combo box?
Private Sub cboReports_AfterUpdate()
    On Error GoTo cboReports_AfterUpdate_Err

    DoCmd.OpenReport Me.cboReports, acViewPreview, "", "", acNormal

cboReports_AfterUpdate_Exit:
    Exit Sub

cboReports_AfterUpdate_Err:
    MsgBox Error$
    Resume cboReports_AfterUpdate_Exit

End Sub

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TAB-000Author Commented:
Issue solved.

Change line from
 tempvars.Add "ReportToOpen", Screen.ActiveControl

Open in new window


to

tempvars.Add "ReportToOpen", (Screen.ActiveControl)

Open in new window


Thanks,
TAB-000Author Commented:
Dear MacroShadow.

I've seen your method much more straight forward, hence it's implemented.

Thanks for your reply and help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.