Hello,
Am getting Expected : Function or VAriable for the following code..
This error means that you have not declared a variable, or didn't make a Function or sub with the expected name. From your code, the problem can be with any of the objects, namely :
Thanks for both of you for your reply. But am still getiing that error. Here is the code which am trying to. Please help me out. Am new to VB. At my work they asked me to do this so am lil scared...
Private Sub cmdUpdate_Click()
' Local Variables
Const strFunctionName = "cmdUpdate_Click"
Dim strSerialNo As Variant
Dim dtDocDate As Date
Dim DocumentID As Long
Dim objRecordset As New Recordset
Set objRecordset = g_objboImaging.UpdateData(strSerialNo, _
dtDocDate, DocumentID)
' Function Exit
FunctionExit:
Exit Sub
' Error Handler
ErrorHandler:
Select Case StandardError(m_strModuleName, strFunctionName)
Case vbAbort: Resume FunctionExit
Case vbRetry: Resume
Case vbIgnore: Resume Next
End Select
Resume FunctionExit
End Sub
and for UpdateData function:::::::::::::::::
Private Sub UpdateData(ByVal strSerialNo As String, ByVal dtDocDate As Date, _
ByVal DocumentID As Long)
10000 ' Local Variables
10010 Dim strFunctionName As String
10020 Dim objRecordset As Recordset
60000 ' Function Exit
FunctionExit:
60010 Exit Sub
70000 ' Error Handler
ErrorHandler:
70010 Select Case StandardError(m_strModuleName, strFunctionName)
Case vbAbort: Resume FunctionExit
Case vbRetry: Resume
Case vbIgnore: Resume Next
70020 End Select
70030 Resume FunctionExit
Public Sub UpdateData( _
ByVal strSerialNo As Variant, _
ByVal dtDocDate As Date, _
ByVal DocumentID As Long)
',
'ByVal AccountNo As Variant
') 'As Recordset
' ByVal UpdateVersion As Variant
'Local Variables
10000 Const strFunctionName = "UpdateData"
10010 Dim objdoImaging2 As doImaging2.clsdoImaging
' Initialization
20000 On Error GoTo ErrorHandler
' Security
' Function
Set objdoImaging2 = m_objContext.CreateInstance(g_strImagingDataObject)
objdoImaging2.UpdateData strSerialNo, dtDocDate, DocumentID
', '_
' AccountNo
', '_
'UpdateVersion
' Return
' m_objContext.SetComplete
FunctionExit:
Exit Sub
' Error Handler
ErrorHandler:
Select Case ServerStandardError(m_strModuleName, strFunctionName, m_strCaller, DocumentID)
Case vbRetry
Resume
Case vbIgnore
Resume Next
Case Else
Resume FunctionExit
End Select
End Sub
and in DataObjects i did:::::::::::::::
Public Sub UpdateData( _
Optional ByVal VIN As Variant, _
Optional ByVal DocumentDate As Date, _
Optional ByVal DocumentID As Long _
)
' Local Variables
Const strFunctionName = "UpdateData"
10000 Dim objCommand As New Command
10010 Dim objRecordset As Recordset
10020 Dim strErrorDescription As String
10120 Dim NewDocumentDate As Date
10130 Dim NewVIN As Variant
' Initialization
10160 On Error GoTo ErrorHandler
' Parameter Validation
30000 If Not ValidateDocument("DocumentID", DocumentID, strErrorDescription) Then Err.Raise g_ErrorInvalidData, , strErrorDescription
30090 If Not IsMissing(DocumentDate) Then If Not ValidateDocument("DocumentDate", DocumentDate, strErrorDescription) Then Err.Raise g_ErrorInvalidData, , strErrorDescription
30100 If Not IsMissing(VIN) Then If Not ValidateDocument("VIN", VIN, strErrorDescription) Then Err.Raise g_ErrorInvalidData, , strErrorDescription
' Error Handler
ErrorHandler:
70000 Select Case ServerStandardError(m_strModuleName, strFunctionName, m_strCaller, _
DocumentID _
)
Case vbRetry
70010 Resume
Case vbIgnore
70020 Resume Next
Case Else
70030 Resume FunctionExit
70040 End Select
End Sub
True they do make it harder to read but they also allow you to pinpoint the line which caused the error once it has been compiled and sent to the end user.
I sometimes add line numbers into potentially troublesome code before sending it to the end user.
There is a method in VB6 to display the line number where the error occurs but in order to use it you must have line numbers in your code before compile. I have used this on occasion and it proved very useful. Normally of course I do not use line numbers in code but they do have thier uses.
I saw a utility somewhere that would add line numbers to your project prior to compile [of course such a thing would be simple to write yourself as well] In a large project this could save many hours of support time.
Bookmarks