Results 1 to 3 of 3
  1. #1
    Jen0dorf is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    UK
    Posts
    453

    macro conversion and tempvars

    Hi



    I created a tempvar using a macro

    and then opened a form.

    I noticed the button to convert macros to vba so I duplicated my form and tried it

    the code created was
    Code:
    '------------------------------------------------------------
    ' btn_Search_Click
    '
    '------------------------------------------------------------
    Private Sub btn_Search_Click()
    
        TempVars.Add "varYear", txtYearOfBaptism
        DoCmd.Close acForm, "frm_BaptismYearSearch"
        DoCmd.OpenForm "frm_BaptismYearSearchResults", acNormal, "", "", , acNormal
    
    End Sub
    but it gives the error

    runtime32438
    TempVars can only storedata. They cannot Store objects

    My Macro works perfectly

    Can anyone tell me what the error is?

    thanks

    Ian

  2. #2
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    It may be interpreting txtYearOfBaptism as the textbox object, rather than the value in it. Try
    TempVars.Add "varYear", txtYearOfBaptism.Value to explicitly specify the value in the textbox.

    (I confess that is only a guess, since I haven't used TempVars!)

  3. #3
    Jen0dorf is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    UK
    Posts
    453
    Hi

    many thanks that did it.

    cheers

    Ian

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

Similar Threads

  1. Replies: 2
    Last Post: 02-20-2015, 06:32 AM
  2. How to use Tempvars in query
    By JrMontgom in forum Programming
    Replies: 3
    Last Post: 09-03-2014, 12:36 PM
  3. TempVars.add and make value ID
    By Ruegen in forum Programming
    Replies: 4
    Last Post: 12-31-2013, 06:19 PM
  4. Tempvars replace formname
    By Ruegen in forum Programming
    Replies: 8
    Last Post: 12-11-2013, 07:45 AM
  5. Using TempVars in query
    By jonesy29847 in forum Programming
    Replies: 3
    Last Post: 03-03-2011, 11:07 PM

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