Results 1 to 4 of 4
  1. #1
    mkenyon2 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    20

    Question 2010 Data Macro weirdness with Parameters

    This is an Access 2010 Web Database



    I have a table, [MaintenanceRequired]. I created a Named Macro, 'MaintReqdNew'.

    The table has 4 columns, ID, Asset (a lookup column linked to the Assets table by the Assets.ID), Detail (a text field), and TypeOfMaint (a lookup column linked to the MaintenanceType table by MaintenanteType.ID).

    The macro has 3 parameters: AssetID, MaintTypeID, and Details.

    I pass in the three values, and the macro does a CreatedRecord, with 3 SetField commands. Asset = [AssetID], Detail = [Details], TypeOfMaint = [MaintTypeID].

    OnError is set to GoTo Next, and the next command is LogEvent Description = [MaintTypeID].

    The record gets created with the correct Asset and Details, but no TypeOfMaint. With no OnError, I get: The field 'TypeOfMaint' cannot accept the data type supplied by SetField.
    With the LogEvent I get the value: [MaintTypeID]

    I tried TypeOfMaint = [MaintTypeID].Value and LogEvent Description = [MaintTypeID].Value, and that's what shows up in the log. I'm pretty sure I'm passing in a valid integer. In the code that calls the macro, I have a TempVar that I dump to a field on the form and then also use to pass to the Macro. The field on the form shows the correct int ID.

    Where am I going wrong? What could I do different? What information haven't I provided that would help you help me?

  2. #2
    mkenyon2 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    20
    Okay, if I change my DataMacro (MaintReqdNew) to have a hard coded MaintTypeID (3) the code works, even though I'm trying to pass in a value of 2 from the main macro from the save button. (I expect the hard coded to overide the passed in value.)

    When I change it back to use the Parameter, it doesn't like the type.

    So, If I hard code with a 3 or 2, it works. But if I pass a 3 or 2, it doesn't.

    Am I passing the value as a string/char instead of as an int? How can I tell?

  3. #3
    hitdrumhard is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    1

    Exclamation Me Too

    I am having the exact problem as you, and I can't yet figure it out. I would love to give this thread a bump to hear if anyone knows how to deal with it.

    I also set a raise error to check the the value of the incoming parameter, and it show it IS getting the int value from the lookup list of the form, so I don't understand what is going on at all.

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    If you're using a value from a combo box it is always going to retrieve the BOUND column, if you are trying to append the DESCRIPTION rather than the ID you're going to get the data type error every time. I suspect you're using a combo box for your MaintTypeID that only lists the text description instead of the ID AND description where the ID field would be the bound column (1) with a width of 0 so the user can not see it. Then when you reference your MaintTypeID it should evaluate as a number instead of a text value.

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

Similar Threads

  1. Access 2010 Macro Help
    By RayMilhon in forum Access
    Replies: 3
    Last Post: 09-30-2011, 12:03 PM
  2. Access 2010 Macro
    By RayMilhon in forum Access
    Replies: 3
    Last Post: 09-28-2011, 11:37 AM
  3. 2007 to 2010 macro won't work
    By lmnnt in forum Programming
    Replies: 6
    Last Post: 08-10-2011, 01:55 PM
  4. Access 2007 Export weirdness - need help
    By Longwell in forum Access
    Replies: 1
    Last Post: 10-17-2010, 11:13 AM
  5. Form to enter all parameters in a macro
    By jackthedog in forum Access
    Replies: 0
    Last Post: 05-05-2009, 04:47 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