• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 390
  • Last Modified:

How to have macro copy a value but not the value when the macro is recorded

I recorded a macro which goes from the sales transaction entry window to the Items (lookup) window.  It then goes back to the sales transaction entry window, pulls up the sales customer detail entry window, clicks on the customer button, copies the customer id, hits "ok" to close the window, hits "ok" to close the sales customer detail entry window, runs a search on the customer id to return items available to that customer.

The purpose of the macro is so our sales entry team only can select items that should be available for the current customer.  The problem is the macro is using the value from when the macro was recorded (ADF-CARROLT-CAR) and not the customer id value for the current record.  Any suggestions?
# DEXVERSION=10.0.313.0 2 2
CheckActiveWin dictionary 'default'  form 'SOP_Entry' window 'SOP_Entry' 
  MoveTo field 'Lookup Button 7' 
  ClickHit field 'Lookup Button 7' 
NewActiveWin dictionary 'SmartList'  form 'IV_Item_Number_Lookup' window 'IV_Item_Number_Lookup' 
ActivateWindow dictionary 'SmartList'  form 'IV_Item_Number_Lookup' window 'IV_Item_Number_Lookup' 
ActivateWindow dictionary 'SmartList'  form 'IV_Item_Number_Lookup' window 'IV_Item_Number_Lookup' 
ActivateWindow dictionary 'SmartList'  form 'IV_Item_Number_Lookup' window 'IV_Item_Number_Lookup' 
ActivateWindow dictionary 'default'  form 'SOP_Entry' window 'SOP_Entry' 
  MoveTo field 'Expansion Button 4' 
  ClickHit field 'Expansion Button 4' 
NewActiveWin dictionary 'default'  form 'SOP_Customer_Detail_Entry' window 'SOP_Customer_Detail_Entry' 
  MoveTo field 'Customer Button' 
  ClickHit field 'Customer Button' 
NewActiveWin dictionary 'default'  form 'RM_Customer_Inquiry' window 'RM_Customer_Inquiry' 
  CommandExec form BuiLtin command cmdEditCopy 
  MoveTo field 'OK Button' 
  ClickHit field 'OK Button' 
NewActiveWin dictionary 'default'  form 'SOP_Customer_Detail_Entry' window 'SOP_Customer_Detail_Entry' 
  MoveTo field 'OK Button' 
  ClickHit field 'OK Button' 
ActivateWindow dictionary 'default'  form 'SOP_Entry' window 'SOP_Entry' 
ActivateWindow dictionary 'default'  form 'SOP_Entry' window 'SOP_Entry' 
ActivateWindow dictionary 'default'  form 'SOP_Entry' window 'SOP_Entry' 
ActivateWindow dictionary 'SmartList'  form 'IV_Item_Number_Lookup' window 'IV_Item_Number_Lookup' 
  MoveTo field 'ASI_LU_View_Button' item 1  # 'All Item Numbers' 
  ClickHit field 'ASI_LU_View_Button' item 2  # 'Customer Items' 
  MoveTo field 'PB_Advanced_Search' 
  ClickHit field 'PB_Advanced_Search' 
NewActiveWin dictionary 'SmartList'  form 'ASI_Advanced_Search' window 'ASI_Explorer_Criteria' 
  MoveTo field 'ASI_Search_Lookup_Button'[1] 
  ClickHit field 'ASI_Search_Lookup_Button'[1] 
NewActiveWin dictionary 'SmartList'  form 'ASI_Explorer_Fields' window 'ASI_Explorer_Fields' 
  MoveTo field '(L) LV_Fields' item 0  # ''
  ClickHitMS field '(L) LV_Fields' item 4  # 'Customer Number'
  SelChanged field '(L) LV_Fields' 
  DblClickHit field '(L) LV_Fields' item 4  # 'Customer Number'
NewActiveWin dictionary 'SmartList'  form 'ASI_Advanced_Search' window 'ASI_Explorer_Criteria' 
  MoveTo field 'ASI_Start_String'[1] 
  CommandExec form BuiLtin command cmdEditPaste 
  TypeTo field 'ASI_Start_String'[1] , 'ADF-CARROLT-CAR'
  MoveTo field 'OK Button K' 
  ClickHit field 'OK Button K' 
NewActiveWin dictionary 'SmartList'  form 'IV_Item_Number_Lookup' window 'IV_Item_Number_Lookup'

Open in new window

0
bradlee27514
Asked:
bradlee27514
1 Solution
 
Jeffrey CoachmanCommented:
bradlee27514,

Obviously, the reference to ADF-CARROLT-CAR (Near the bottom of your snippet), needs to be "Relative"

Meaning it should be something like "CurrentRecord" or "CurrentCustomer"
something like this:
    TypeTo field 'ASI_Start_String'[1] , CurrentCustomer
How that is done in Dynamics, I am not sure.

The other option would be to store the Current Customer record as a variable, and use that.

For example:
Dim strCurrentCustomer as string
CurrentCustomer=Me.CurrentCustomer

Then in your code the line would be:

    TypeTo field 'ASI_Start_String'[1] , strCurrentCustomer

Now all of this is in "Global" terms, and is meant to give you an Idea of what needs to happen.

You can wait for another Expert (More experienced in MSDynamics Macro Recording) to chime in.

But my company uses Dynamics as well, and we have found that the technical support is superb.
Did you try giving them a call?

JeffCoachman
0
 
Computer101Commented:
PAQed with no points refunded (of 500)

Computer101
EE Admin
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now