what is the proper syntax to set the value of a button/control to difference functions depending on which phase of the the process the user is in?
I am in the process of converting and cleaning up old Macro code into vba. It does not like the setting of a control/button.
I have a form where the "ok" button could launch 1 of 3 functions to be used. Like if field 3 = FTIRDN then it should execute the function named: FM_ViDataX_ApSelect_FTIR_O
Private Sub cmd_ImportFTIR_Click()
Dim i As Integer
On Error GoTo cmd_ImportFTIR_Click_Error
gApNO = Me.ApNo
' FM_ViDataX_ApSelect - Form - - - Edit - Normal ==> Self Explanatory
DoCmd.OpenForm "FM_ViDataX_ApSelect", acNormal, "", "", acEdit, acNormal
'-- Set the initial form values.
Forms![FM_ViDataX_ApSelect]![txtApNo].Value = UCase$(Trim$(gApNO))
Forms![FM_ViDataX_ApSelect]![txtFileName].Value = gApNO & "\Access\FTIR.txt"
' ViDataX_Set_FTIR_Values - Code ==> Set the default FTIR download values for FM_ViDataX_ApSelect form.
Forms![FM_ViDataX_ApSelect]![txtXactnName].Value = "FTIRDN"
' Sets the click event on the OK button to run FM_ViDataX_ApSelect._FTIR_OK
i = 1
' Forms!FM_ViDataX_ApSelect!cmdOK.OnClick = "FM_ViDataX_ApSelect_FTIR_OK"
On Error GoTo 0
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cmd_ImportFTIR_Click of VBA Document Form_FS_MSB"
As you can see I have tried it within the quotes and it gives me an error msg. Can't find the object FM_ViDataX_ApSelect_FTIR_O
and if I try it w/o the quotes then it just executes the code automatically.
Please keep in mind that this OK button should be used in 3 different instances using different function names. What is the proper syntax?