Results 1 to 4 of 4
  1. #1
    dollarazzel is offline Novice
    Windows 10 Office 365
    Join Date
    Jun 2020
    Posts
    2

    Unhappy Why do I get a TempVars Only Store Data not Objects when TempVars Store objects

    I was recently volunteered to finish off a Access database that a colleague had completed about 99% of before she left to another job. the db is being used as a Library Check In/Check Out database.


    There is an action button that 'On Click' runs an Event procedure that is written in VBA. Upon clicking the action button I get the error "TempVars can only store data, they cannot store objects".
    I don't have any prior experience with VBA or Access so I don't what's broken or how to fix. Any help would be greatly appreciated

    Code:
    
    '------------------------------------------------------------
    ' Action_Click
    '
    '------------------------------------------------------------
    Private Sub Action_Click()
    On Error GoTo Action_Click_Err
    
    
        ' _AXL:<?xml version="1.0" encoding="UTF-16" standalone="no"?>
        ' <UserInterfaceMacro For="Owner" xmlns="http://schemas.microsoft.com/office/accessservices/2009/11/application"><Statements><ConditionalBlock><If><Condition>IsNull([Screen].[ActiveControl])</C
        ' _AXL:ondition><Statements><Action Name="StopMacro"/></Statements></If></ConditionalBlock><Action Name="OpenForm"><Argument Name="FormName">Contact Details</Argument><Argument Name="WhereCondition">="[ID]=" &amp; [Screen].[ActiveControl]</Argument><Argum
        ' _AXL:ent Name="WindowMode">Dialog</Argument></Action><Action Name="OnError"/><Action Name="Requery"><Argument Name="ControlName">=[Screen].[ActiveControl].[Name]</Argument></Action></Statements></UserInterfaceMacro>
        If (IsNull(ID)) Then
            Beep
            Exit Sub
        End If
        TempVars.Add "ItemID", ID
        If (Nz([Contact Name]) <> "") Then
            DoCmd.OpenForm "Check In", acNormal, "", "[Transactions].[Asset]=[TempVars]![ItemID] And [Transactions].[Checked In Date] Is Null", acEdit, acDialog
        End If
        If (Nz([Contact Name]) = "") Then
            DoCmd.OpenForm "Check Out", acNormal, "", "1=0", acEdit, acDialog
        End If
        DoCmd.Requery ""
    
    
    
    
    Action_Click_Exit:
        Exit Sub
    
    
    Action_Click_Err:
        MsgBox Error$
        Resume Action_Click_Exit
    
    
    End Sub

  2. #2
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,404
    Change line to
    Tempvars.Add "ItemID", ID.Value
    Last edited by davegri; 06-23-2020 at 10:27 PM. Reason: syntax

  3. #3
    dollarazzel is offline Novice
    Windows 10 Office 365
    Join Date
    Jun 2020
    Posts
    2
    Thanks davegri, that fixed the issue!

    Cheers

  4. #4
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,404
    Glad to help. That code was generated by Access converting an embedded macro to VBA. Microsoft sometimes has problems doing that and needs a bit of cleanup.
    Good luck with finishing up the project.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 10
    Last Post: 08-27-2017, 09:00 PM
  2. How to use Tempvars in query
    By JrMontgom in forum Programming
    Replies: 3
    Last Post: 09-03-2014, 12:36 PM
  3. Replies: 9
    Last Post: 04-01-2014, 05:06 PM
  4. TempVars.add and make value ID
    By Ruegen in forum Programming
    Replies: 4
    Last Post: 12-31-2013, 06:19 PM
  5. Using TempVars in query
    By jonesy29847 in forum Programming
    Replies: 3
    Last Post: 03-03-2011, 11:07 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums