-
October 9th, 2009, 12:32 PM
#1
Getting Function or Variable not found error
Hello,
Am getting Expected : Function or VAriable for the following code..
Set objRecordset = g_objboImaging.UpdateData(strSerialNo, _
dtDocDate, DocumentID)
Please help me...
Thanks in Advance...
-
October 9th, 2009, 05:12 PM
#2
Re: Getting Function or Variable not found error
The problem lies in this part:
Code:
g_objboImaging.UpdateData(strSerialNo, _
dtDocDate, DocumentID)
that should help, but if you really wanted help, you'd show where you declared those variables / function to UpdataData
-
October 10th, 2009, 02:58 AM
#3
Re: Getting Function or Variable not found error
Originally Posted by Yukie
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 :
objRecordset,
g_objboImaging
UpdateData,
strSerialNo,
dtDocDate,
DocumentID
Make sure all these objects are delared, and that you indeed have a function named UpdateData
Another problem may be that you are trying to use an object from certain class, without instantiating that class beforehand.
Agin, from your code, I gather that g_objboImaging must be an object representing a certain class, and that class wasn't instantiated.
To instantiate a class object variable, you must use the keyword New upon declaration.
I hope my advice was helpful
-
October 12th, 2009, 10:22 AM
#4
Re: Getting Function or Variable not found error
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
' Initialization
On Error GoTo ErrorHandler
' Function
'
UpdateData txtUpdatedSerialNo, txtUpdatedDocDate, txtDocID
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
20000 ' Initialization
20010 On Error GoTo ErrorHandler
20020 strFunctionName = "UpdateData"
30000 ' Function
30010 m_objDocuments!strSerialNo = txtUpdatedSerialNo
30020 m_objDocuments!dtDocDate = txtUpdatedDocDate
30030 m_objDocuments!DocumentID = txtDocID
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
Screen.MousePointer = vbHourglass
strSerialNo = txtUpdatedSerialNo
dtDocDate = txtUpdatedDocDate
DocumentID = txtDocID
End Sub
and In business objects i did ::::::::::::::::
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
40180 NewDocumentDate = IIf(IsMissing(DocumentDate), objRecordset!DocumentDate, DocumentDate)
40190 NewVIN = IIf(IsMissing(VIN), objRecordset!VIN, VIN)
40200 objCommand.ActiveConnection = g_dbImaging2ConnectString
40210 objCommand.CommandText = "UpdateSerialNoAndDocDate"
40220 objCommand.CommandType = adCmdStoredProc
40230 objCommand.Parameters.Append objCommand.CreateParameter("@DocumentID", adInteger, adParamInput, , DocumentID)
40320 objCommand.Parameters.Append objCommand.CreateParameter("@DocumentDate", adDBTimeStamp, adParamInput, , NewDocumentDate)
40330 objCommand.Parameters.Append objCommand.CreateParameter("@VIN", adVarChar, adParamInput, 100, NewVIN)
40390 Set objCommand = Nothing
50130 Set objRecordset = Nothing
' Return
'60000 m_objContext.SetComplete
FunctionExit:
60010 Exit Sub
' 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
Please help me....
Thanks in Advanace.........
-
October 12th, 2009, 05:42 PM
#5
Re: Getting Function or Variable not found error
Please use
Code:
' Code Tags like THIS
-
October 13th, 2009, 11:05 AM
#6
Re: Getting Function or Variable not found error
And the code would be even more legible if you wouldn't use those antique line numbers.
This is not MBasic, after all.
-
October 14th, 2009, 05:22 AM
#7
Re: Getting Function or Variable not found error
Line numbers can be a good thing.
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.
-
October 14th, 2009, 05:43 PM
#8
Re: Getting Function or Variable not found error
I haven't seen a line number used since college classes a for 'legibility', and before that was COBOL, which NEEDED them.
They are useful for cross-reference listings (but I haven't seen one of those since QB 4.5.
-
October 14th, 2009, 07:57 PM
#9
Re: Getting Function or Variable not found error
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|