G
Guest
I'm constructing an Access 2000 database, which calls a VB sub routine, when
a command button is clicked, to open a form, which then calls a converted
Macro function routine to set several field values from the original form.
The function routine does set the specified field values and then stops with
an "Object required" message. Clicking on the OK exits the sub routine
without executing the remaining code of the function routine or the sub
routine from which it was called.
What object is Access / VB looking for ? I've been unable to find anything
in either Access or the VB help files.
I've included the VB code for both the sub routine and the called function
below.
Private Sub Cmd_ArrangeService_Click()
On Error GoTo Err_Cmd_ArrangeService_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Service Work"
DoCmd.OpenForm stDocName, , , stLinkCriteria
'Module Converted Macro-Service Work
RunCode.Function Service_Work()
stDocName = "Customers"
DoCmd.Close acForm, stDocName, acSaveYes
Exit_Cmd_ArrangeService_Click:
Exit Sub
Err_Cmd_ArrangeService_Click:
MsgBox Err.Description
Resume Exit_Cmd_ArrangeService_Click
End Sub
'------------------------------------------------------
'------------------------------------------------------
Function Service_Work()
On Error GoTo Service_Work_Err
With CodeContextObject
Forms!Service_Work!CustomerName = Forms!Customers!CustomerName
Forms!Service_Work!CustomerID = Forms!Customers!CustomerID
Forms!Service_Work!EquipmentID = .EquipmentID
Forms!Service_Work!Equipment = .Equipment
Forms!Service_Work!HeatSource = .HeatSource
Forms!Service_Work!EquipmentSerialNumber = .EquipmentSerialNumber
DoCmd.GoToControl "CustomerContact"
End With
Service_Work_Exit:
Exit Function
Service_Work_Err:
MsgBox Error$
Resume Service_Work_Exit
End Function
Hope someone can help.
Many thanks
Nicholas @ Double D
a command button is clicked, to open a form, which then calls a converted
Macro function routine to set several field values from the original form.
The function routine does set the specified field values and then stops with
an "Object required" message. Clicking on the OK exits the sub routine
without executing the remaining code of the function routine or the sub
routine from which it was called.
What object is Access / VB looking for ? I've been unable to find anything
in either Access or the VB help files.
I've included the VB code for both the sub routine and the called function
below.
Private Sub Cmd_ArrangeService_Click()
On Error GoTo Err_Cmd_ArrangeService_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Service Work"
DoCmd.OpenForm stDocName, , , stLinkCriteria
'Module Converted Macro-Service Work
RunCode.Function Service_Work()
stDocName = "Customers"
DoCmd.Close acForm, stDocName, acSaveYes
Exit_Cmd_ArrangeService_Click:
Exit Sub
Err_Cmd_ArrangeService_Click:
MsgBox Err.Description
Resume Exit_Cmd_ArrangeService_Click
End Sub
'------------------------------------------------------
'------------------------------------------------------
Function Service_Work()
On Error GoTo Service_Work_Err
With CodeContextObject
Forms!Service_Work!CustomerName = Forms!Customers!CustomerName
Forms!Service_Work!CustomerID = Forms!Customers!CustomerID
Forms!Service_Work!EquipmentID = .EquipmentID
Forms!Service_Work!Equipment = .Equipment
Forms!Service_Work!HeatSource = .HeatSource
Forms!Service_Work!EquipmentSerialNumber = .EquipmentSerialNumber
DoCmd.GoToControl "CustomerContact"
End With
Service_Work_Exit:
Exit Function
Service_Work_Err:
MsgBox Error$
Resume Service_Work_Exit
End Function
Hope someone can help.
Many thanks
Nicholas @ Double D