Crystal Script condition statement 'This field name is not known' error - crystal-reports

this is my current condition statement
IF {AR_DEBIT.InvoiceNo} = "" THEN {AR_DEBIT.Description}
ELSE {AR_DEBIT.Description} & "(" & {AR_DEBIT.InvoiceNo} & " - " & ToText({AR_DEBIT.InvoiceDate}, "dd-MMM-yyyy") & ")"
not working...prompt error IF {AR_DEBIT.InvoiceNo} = "" THEN this field is not known bla bla something like that...
when i remove the condition,
{AR_DEBIT.Description} & "(" & {AR_DEBIT.InvoiceNo} & " - " & ToText({AR_DEBIT.InvoiceDate}, "dd-MMM-yyyy") & ")"
the report show no error...anybody?

Related

Error at the end of the statement SSRS expression , couldn"t find it?

=
"<b>"+ "Created on: " + "</b>" & CDate(Fields!ticket_ticketSolutions_date_create.Value).ToString("dd/MM/yy HH:mm"))
& Environment.NewLine
& "<b>" + "Approval date: " + "</b>" & iif (IsNothing(Fields!date_approval.value),"Not Approved",CDate( Fields!date_approval.Value).ToString("dd/MM/yy HH:mm"))
& Environment.NewLine
& "<b>" + "Solutions: " +"</b>" & Fields!ticket_ticketSolutions_content_plainText.Value
The Value expression for the textrun 'solution_all.Paragraphs[0].TextRuns[0]' contains an error: [BC30205] End of statement expected.
The definition of the report '' is invalid.
I don't understand where are my errors ?? as I created a calculated fields that contains this formula
You have mis-matching )s on line 2 . Remove the end ).

Is there a way to wrap text in Excel VBA form listbox?

Is there a way to wrap text in Excel VBA form listbox?
item = item & WorksheetFunction.Rept(" ",30 - Len(item))
subtotal = WorksheetFunction.Rept(" ", 10 - subtotal_pad) & _
"$ " & WorksheetFunction.Rept(" ", subtotal_pad - Len(Format(subtotal, "0.00"))) & Format(subtotal, "0.00")
taxed = " "
If tax_rate <> 0 Then
taxed = " T"
End If
description = ""
If description <> "" Then
description = vbNewLine & " - " & description
End If
quantity = ""
If unit <> "ea" Then
quantity = vbNewLine & " - " & quantity & " # $" & Format(cost, "0.00#") & "/" & unit
End If
lbxCharges.AddItem (item & subtotal & taxed & description & quantity)
This is how it looks:
but this is how it should look:

Tracking Chnages in Enterprise Architect

I encounter a real difficulty in tracking changes and updates in the company models.
I research the tool abilities a lot, but still didn't find the golden way that match my requirements of:
Provide indication where was a change
What was the change
Keep the original model state, aside to the up-to-date state
EA offers the following ways:
Baselines
Version Control
Clone
Change Elements
None of them provides indication on what exactly was the change and where.
What is the easiest way to manage the changes effectively?
You forgot the last resort: audit. Turn on auditing and you can get a lot more information. Of course this also has its drawbacks
it uses a lot of space
there are still changes that are not tracked in the detail you might need it.
Turn it on at Project/Auditing. More information here.
Additionally you could think of writing triggers, but I would not recommend that since it makes your repository almost unmaintainable.
Auditing is of course also no silver bullet. Tracking changes is tedious. And personally I would not spend too much effort in this "accusation mode". Better spend your energy in driving the model towards the company goals. Nobody needs yesterday's model.
I wrote some scripts to handle change management in EA.
The idea is that the user links the changed items to a change request element that represents a workitem, project, change request, bug,...
Each link contains the date, user and a comment for the change to that item.
The scripts are part of the open source EA VBScript library:
The main script is the following
'[path=\Projects\Project A\A Scripts]
'[group=Atrias Scripts]
!INC Local Scripts.EAConstants-VBScript
!INC Atrias Scripts.Util
' Script Name: LinkToCRMain
' Author: Geert Bellekens
' Purpose: Link Elemnents to a change
' Date: 2015-10-30
'
'
function linkItemToCR(selectedItem, selectedItems)
dim groupProcessing
groupProcessing = false
'if the collection is given then we initialize the first item.
if selectedItem is nothing then
if not selectedItems is nothing then
if selectedItems.Count > 0 then
set selectedItem = selectedItems(0)
if selectedItems.Count > 1 then
groupProcessing = true
end if
end if
end if
end if
if selectedItem is nothing then
set selectedItem = Repository.GetContextObject()
end if
'get the select context item type
dim selectedItemType
selectedItemType = selectedItem.ObjectType
select case selectedItemType
case otElement, otPackage, otAttribute, otMethod, otConnector :
'if the selectedItem is a package then we use the Element part of the package
if selectedItemType = otPackage then
set selectedItem = selectedItem.Element
end if
'get the logged in user
Dim userLogin
userLogin = getUserLogin
dim lastCR as EA.Element
set lastCR = nothing
dim CRtoUse as EA.Element
set CRtoUse = nothing
set lastCR = getLastUsedCR(userLogin)
'get most recent used CR by this user
if not selectedItem is nothing then
dim lastComments
lastComments = vbNullString
'if there is a last CR then we ask the user if we need to use that one
if not lastCR is nothing then
dim response
if groupProcessing then
response = Msgbox("Link all " & selectedItems.Count & " elements to change: """ & lastCR.Name & """?", vbYesNoCancel+vbQuestion, "Link to CR")
elseif not isCRLinked(selectedItem,lastCR) then
response = Msgbox("Link element """ & selectedItem.Name & """ to change: """ & lastCR.Name & """?", vbYesNoCancel+vbQuestion, "Link to CR")
end if
'check the response
select case response
case vbYes
set CRToUse = lastCR
case vbCancel
'user cancelled, stop altogether
Exit function
end select
end if
'If there was no last CR, or the user didn't want to link that one we let the user choose one
if CRToUse is nothing then
dim CR_id
CR_ID = Repository.InvokeConstructPicker("IncludedTypes=Change")
if CR_ID > 0 then
set CRToUse = Repository.GetElementByID(CR_ID)
end if
else
'user selected same change as last time. So he might want to reuse his comments as well
lastComments = getLastUsedComment(userLogin)
end if
'if the CRtoUse is now selected then we link it to the selected element
if not CRToUse is nothing then
dim linkCounter
linkCounter = 0
'first check if this CR is not already linked
if isCRLinked(selectedItem,CRToUse) and not groupProcessing then
MsgBox "The CR was already linked to this item", vbOKOnly + vbExclamation ,"Already Linked"
else
'get the comments to use
dim comments
comments = InputBox("Please enter comments for this change", "Change Comments",lastComments)
if len(comments) > 2 then
if groupProcessing then
for each selectedItem in selectedItems
'check the object type
selectedItemType = selectedItem.ObjectType
select case selectedItemType
case otElement, otPackage, otAttribute, otMethod, otConnector :
if not isCRLinked(selectedItem,CRToUse) then
linkToCR selectedItem, selectedItemType, CRToUse, userLogin, comments
linkCounter = linkCounter + 1
end if
end select
next
if linkCounter > 0 then
MsgBox "Successfully linked " & selectedItems.Count & " elements to change """ & CRToUse.Name& """" , vbOKOnly + vbInformation ,"Elements linked"
else
MsgBox "No links created to change " & CRToUse.Name & "." & vbNewLine & "They are probably already linked" , vbOKOnly + vbExclamation ,"Already Linked"
end if
else
linkToCR selectedItem, selectedItemType, CRToUse, userLogin, comments
end if
else
MsgBox "The CR has not been linked because no comment was provided", vbOKOnly + vbExclamation ,"No CR link"
end if
end if
end if
end if
case else
MsgBox "Cannot link this type of element to a CR" & vbNewline & "Supported element types are: Element, Package, Attribute, Operation and Relation"
end select
end function
function isCRLinked(item, CR)
dim taggedValue as EA.TaggedValue
isCRLinked = false
for each taggedValue in item.TaggedValues
if taggedValue.Value = CR.ElementGUID then
isCRLinked = true
exit for
end if
next
end function
function linkToCR(selectedItem, selectedItemType, CRToUse, userLogin, comments)
Session.Output "CRToUse: " & CRToUse.Name & " userLogin: " & userLogin & " comments: " & comments
dim crTag
set crTag = nothing
set crTag = selectedItem.TaggedValues.AddNew("CR","")
if not crTag is nothing then
crTag.Value = CRToUse.ElementGUID
crTag.Notes = "user=" & userLogin & ";" & _
"date=" & Year(Date) & "-" & Right("0" & Month(Date),2) & "-" & Right("0" & Day(Date),2) & ";" & _
"comments=" & comments
crTag.Update
end if
end function
function getLastUsedCR(userLogin)
dim wildcard
dim sqlDateString
if Repository.RepositoryType = "JET" then
wildcard = "*"
sqlDateString = " mid(tv.Notes, instr(tv.[Notes],'date=') + len('date='),10) "
Else
wildcard = "%"
sqlDateString = " substring(tv.Notes, charindex('date=',tv.[Notes]) + len('date='),10) "
end if
dim sqlGetString
sqlGetString = "select top 1 o.Object_id " & _
" from (t_objectproperties tv " & _
" inner join t_object o on o.ea_guid = tv.VALUE) " & _
" where tv.[Notes] like 'user=" & userLogin & ";" & wildcard & "' " & _
" order by " & sqlDateString & " desc, tv.PropertyID desc "
dim CRs
dim CR as EA.Element
set CR = nothing
'get the last CR
set CRs = getElementsFromQuery(sqlGetString)
if CRs.Count > 0 then
set CR = CRs(0)
end if
set getLastUsedCR = CR
end function
function getLastUsedComment(userLogin)
dim wildcard
dim sqlDateString
dim sqlCommentsString
if Repository.RepositoryType = "JET" then
wildcard = "*"
sqlDateString = " mid(tv.Notes, instr(tv.[Notes],'date=') + len('date='),10) "
sqlCommentsString = " mid(tv.Notes, instr(tv.[Notes],'comments=') + len('comments=')) "
Else
wildcard = "%"
sqlDateString = " substring(tv.Notes, charindex('date=',tv.[Notes]) + len('date='),10) "
sqlCommentsString = " substring(tv.Notes, charindex('comments=',tv.[Notes]) + len('comments='), datalength(tv.Notes)) "
end if
dim sqlGetString
sqlGetString = "select top 1 " & sqlCommentsString & " as comments " & _
" from (t_objectproperties tv " & _
" inner join t_object o on o.ea_guid = tv.VALUE) " & _
" where tv.[Notes] like 'user=" & userLogin & ";" & wildcard & "' " & _
" order by " & sqlDateString & " desc, tv.PropertyID desc "
dim queryResult
queryResult = Repository.SQLQuery(sqlGetString)
Session.Output queryResult
dim results
results = convertQueryResultToArray(queryResult)
if Ubound(results) > 0 then
getLastUsedComment = results(0,0)
else
getLastUsedComment = vbNullString
end if
end function

VBA Access Compile Error - Data Member Not Found - How to ignore?

I have the code below in a button in my forms in MS Access. The problem is that sometimes not all "strCTRL"s exist. In some forms they do, in some they don't. The whole code is 900+ lines long so I won't post all of it. It's a SQL query which references controls and extracts their value.
The problem comes when not all controls are present, then I get the error: Compile error: Method or data Member not found.
Is there a way to bypass the compile error or tell VBA to compile it only if it exists? I tried If...Nothing and On Error Resume Next, but they don't seem to work. There's also other objects that will not exist on each page, not just the ones below. So...any ideas? =/
Dim strCTRL1 As String
Dim strCTRL2 As String
Dim strCTRL3 As String
Dim strCTRL4 As String
Dim strCTRL5 As String
Dim strCTRL6 As String
Dim strCTRL7 As String
Dim strCTRL8 As String
Dim strCTRL9 As String
Dim strCTRL10 As String
DoCmd.SetWarnings False
On Error Resume Next
strCTRL1 = "[Control Number] = " & Me.Text684.DefaultValue & " "
strCTRL2 = "[Control Number] = " & Me.Label2210.DefaultValue & " "
strCTRL3 = "[Control Number] = " & Me.Label2295.DefaultValue & " "
strCTRL4 = "[Control Number] = " & Me.Label73.DefaultValue & " "
strCTRL5 = "[Control Number] = " & Me.Label160.DefaultValue & " "
strCTRL6 = "[Control Number] = " & Me.Label246.DefaultValue & " "
strCTRL7 = "[Control Number] = " & Me.Label332.DefaultValue & " "
strCTRL8 = "[Control Number] = " & Me.Label417.DefaultValue & " "
strCTRL9 = "[Control Number] = " & Me.Label506.DefaultValue & " "
strCTRL10 = "[Control Number] = " & Me.Text2285.DefaultValue & " "
You can create an array or list of the label names, then:
Dim LabelName As String
Dim LabelNames As Variant
LabelNames = Array("Text684", "Label2210", ...etc.)
' ...
LabelName = LabelNames(1)
strCTRL1 = "[Control Number] = " & Me(LabelName).DefaultValue & " "
That will compile, though - of course - fail at runtime for non-existing labels.
OK, thanks to #Gustav, you got your code to compile, and his suggestions, combined with On Error Resume Next will get your code to run without errors under any circumstance.
But there is no way to tell if your code is correct, because now, the compiler won't tell you which controls are misnamed or missing.
So instead, I would suggest an array-based approach like this:
Dim Ctl As Access.Control
Dim CtlValues() As String
Dim i as Long
i = 0
ReDim CtlValues 1 To Me.Controls.Count
For Each Ctl In Me.Controls
If Ctl.ControlType = acTextBox Then
i = i + 1
CtlValues(i) = "[Control Number] = " & CStr(Nz(Ctl.DefaultValue, "Null"))
End If
Next
ReDim Preserve CtlValues 1 To i
These 12 lines of code perform the same task that the 900 lines do (going by your example). This code will work in any form, regardless of how many controls there are, and what they are named. This code is way easier to understand and work with.
See if maybe an approach like this will work here.

Form Search to find all records with value in subform (regardless of field value in)

After searching the forum, I haven't found any questions/answers quite like mine.
I have a main form with four different search fields - last name, city, phone number, and ID. I want to have a search of any of these fields (or combination of these fields) to find all records in the subform with a matching value - regardless of which field that value is in (i.e. there are multiple address fields in the subform, so the city could appear in any of these).
Additionally, if a Last Name AND City are entered I only want to return records in the subform that include both values.
Thank you in advance!
I don't think this can be done without employing VBA. You would need to add code to the AfterUpdate event for each search field's control on the main form that would subsequently update the subform's filter. I'm not sure how complex filters are allowed to be, though, which could be a problem because it's going to be a monster of a filter.
Here's an untested example that uses placeholders for the potential number of different fields in the subform (as you indicated there could be multiples of any of them) and assuming your phone number and ID are numbers and that your search controls have data validation in place to ensure that:
Private Sub last_name_AfterUpdate()
Call FilterSubForm()
End Sub
Private Sub city_AfterUpdate()
Call FilterSubForm()
End Sub
Private Sub phone_number_AfterUpdate()
Call FilterSubForm()
End Sub
Private Sub ID_AfterUpdate()
Call FilterSubForm()
End Sub
Private Sub FilterSubForm()
Dim sLastName As String
Dim sCity As String
Dim sPhone As String
Dim sID As String
Dim sFilter As String
sLastName = Trim(Me.[last name])
sCity = Trim(Me.city)
sPhone = Trim(Me.[phone number])
sID = Trim(Me.ID)
If sLastName != "" And sCity != "" Then
sFilter = "(([last_name_1] = '" & sLastName & "' " _
& "OR [last_name_2] = '" & sLastName & "' " _
& "OR [last_name_etc] = '" & sLastName & "') " _
& "AND " _
& "([city_1] = '" & sCity & "' " _
& "OR [city_2] = '" & sCity & "' " _
& "OR [city_etc] = '" & sCity & "'))"
If sPhone != "" Then
sFilter = sFilter _
& " AND " _
& "[phone_number_1] = " & sPhone & " " _
& "OR [phone_number_2] = " & sPhone & " " _
& "OR [phone_number_etc] = " & sPhone
End If
If sID != "" Then
sFilter = sFilter _
& IIf(sPhone != "", " OR ", " AND ") _
& "[ID_1] = " & sID & " " _
& "OR [ID_2] = " & sID & " " _
& "OR [ID_etc] = " & sID
End If
Else
If sLastName != "" Then
sFilter = "[last_name_1] = '" & sLastName & "' " _
& "OR [last_name_2] = '" & sLastName & "' " _
& "OR [last_name_etc] = '" & sLastName & "'"
End If
If sCity != "" Then
sFilter = sFilter _
& IIf(sLastName != "", " OR ", "") _
& "[city_1] = '" & sCity & "' " _
& "OR [city_2] = '" & sCity & "' " _
& "OR [city_etc] = '" & sCity & "'"
End If
If sPhone != "" Then
sFilter = sFilter _
& IIf(sCity != "", " OR ", "") _
& "[phone_number_1] = " & sPhone & " " _
& "OR [phone_number_2] = " & sPhone & " " _
& "OR [phone_number_etc] = " & sPhone
End If
If sID != "" Then
sFilter = sFilter _
& IIf(sPhone != "", " OR ", "") _
& "[ID_1] = " & sID & " " _
& "OR [ID_2] = " & sID & " " _
& "OR [ID_etc] = " & sID
End If
End If
Me.[your_subform].Filter = sFilter
Me.[your_subform].FilterOn = True
Me.[your_subform].Requery
End Sub