how to save null value in subsonic - subsonic

Dim xbg As Rm
xbg.LobId = cmb_lob.SelectedValue
xbg.Mobile = mobno.Text
xbg.BusinessFax = faxno.Text
xbg.BusinessPhone = phno.Text
xbg.Save()
I have a combo box, which is not mandatory while input in the module. therefore user can select blank value in combo cox for which i want to save null in Oracle Database for that record. I had trid with following condition but fails to get result. you are requested to please help
if cmb_lob.selectedindex=-1 then
xbg.lob=dbnull
else
xbg.LobId = cmb_lob.SelectedValue
Actual Problem arises when first user save record with selection in Combo box then user edit that record and select blank from Combo box. now i have to replace value of combox box with null at database.

Set it to null or whatever VB considers null - it will be set in the DB that way.

try:
if cmb_lob.selectedindex <> -1 then
xbg.LobId = cmb_lob.SelectedValue
else
xbg.LobId = Nothing 'suggested by John Shean (see comments)
So that if the value is selected only then assign it to field else leave it as it is (null)

Try xbg.LobId = Nothing instead –
By John Sheehan

Related

Changing Value of Combo Box to another Value in VB

I am trying to change the value of a combo box value "Black Shredded - 7.90" to just show "Black Shredded" when it is selected
Dim intIndex As Integer
Dim strString1 As String
Dim strString2 As String
strString1 = cboProduct.SelectedItem
intIndex = strString1.IndexOf(" ")
strString2 = strString1.Remove(intIndex + 9)
If cboProduct.SelectedIndex = 0 Then
cboProduct.Text = strString2
End If
I went through the values and they show as they should but it isn't changing the combobox value what could I be doing wrong?
If you have just added Strings to the ComboBox in the first place then you need to replace the existing item with the new value. This:
cboProduct.Text = strString2
should be this:
cboProduct.Items(cboProduct.SelectedIndex) = strString2
You can just use 0 rather than cboProduct.SelectedIndex, given that you have already confirmed that that is the index at that point.
Setting the Text property doesn't affect the items at all. If DropDownStyle is set to DropDown then the specified text will be displayed but no item will be selected. If DropDownStyle is set to DropDownList then the item with that text will be selected, if one exists. Either way, no item is added or changed.

Run Time design change in lotusnotes

I need to change the name and formula of columns of a embedded view in a lotus notes dialog box.I need to change this column name and formula when a combo box value in dialog box changes.i added the lotus script to change the column name and formula on combo box value change and added code to reopen the dialog box.
Dim w As New NotesUIWorkspace
Dim view As NotesView
Dim col As NotesViewColumn
Set view = db.GetView("Test")
For j= 0 To UBound(SboxColName)
Set col=view.Columns(j)
col.Title=SboxColName(j)
col.Formula=SboxColFormula(j)
Next
Call w.Viewrefresh()
But the view column not get updated in next open, it gets updated only when i open the view in designer and save the view. when i open this view in designer i can see that the column is updated in the design.
Is there any way to get this embedded view column updated in runtime
In past I used this code in server agent, has worked fine.
I changed DateTime value in column for coloring rows (copy column and change formula).
After that i had send command to rebuild view in db.
Set view = db.Getview(*viewName*)
Set clm = view.Columns(3)
Set Newclm = view.Copycolumn(clm, 5)
Call view.Refresh()
Newclm.Formula = {#If( [} & Today & {] > #Date(DTContol); 255:0:0;-1 : -1 : -1 : -1 : -1 : -1)}
Call view.Removecolumn(4)
CommandText = {load updall } & db.Filepath & { -t } & view.Name & { -r}
Call session.Sendconsolecommand(db.Server, CommandText)
On Client: Maybe Call ws.Viewrefresh() will be sufficient

Lotus Notes: Comparing two fields

I have two dialoglist fields Cutt_Start and Cutt_End, both of the fields has example choices of: January | 1
February | 2
March | 3
...
December | 12
Now, what I want to happen is that, when you select January on the Cutt_Startand March on the Cutt_End, it should prompt an error that Month2 should be next to Month1. I tried this code, but nothing happens.
If Cutt_Start = "January" & Cutt_End <> "February" Then
Msgbox "Month2 should be next to Month1"
Else
Msgbox "January to February selected"
End If
Can you help me?
As already mentioned, the stored field values are the ones right of the pipe. BUT: such fields are always text- fields!!!!
To do a computation, you need to transform the text to numbers...
_start := #TextToNumber( Cutt_Start );
_end := #TextToNumber( Cutt_End );
_res := _end - #Modulo(_start; 12)
#If( !#IsError(_res) &_res != 1; #Failure( "your message" ); #Success)
This goes into the field validation of the Cutt_end- field.
If you need LotusScript (to have it in the QuerySave or the OnChange-Event of the field, then the code would be:
Option declare
Dim ws as New NotosUiWorkspace
Dim doc as NotesDocument
Set doc = ws.CurrentDocument.Document
If Cint(doc.Cutt_End) - CInt(doc.Cutt_Start) <> 1 then
messagebox "your Message"
End if
This code does NOT contain any errror handler.
And as mentioned in the other comments: this for sure is not the right way to do it. If cut_end always has to be one month later, then simply change it to computed and write as value:
#If(Cutt_Start = ""; ""; #Text(#Modulo(#TextToNumber( Cutt_Start ); 12) + 1))
Then you would not need to make your check...
The number to the right of the pipe character is the value of the field. The name to the left of the pipe is what is displayed to the user.
So if you just test that the numbers are sequential, and add a special case for Dec to Jan (1 comes after 12) then you should get the result you are looking for.
Note that the number value is still in text format so you'll need to cast it to a number first
If Cutt_End - Cutt_Start <> 1 Then Msgbox "Error!"
That said, if the Cutt_End must always be 1 month after Cutt_Start, then why have that field at all? Just calculate that field and make the user just choose the start month.
Please check the following and put your code into the onchange event. For web and the notes client the onchange function behavior is different.

Filtering a Pivot Table Automatically in Excel

I'm building a DB for school activities in the afternoon. I'm trying to create a search option through a form that controls a pivot table in which the user can filter on the class type and/or the age group and or the school year.
I wrote this code in VBA and it's not working. When i tried to write a code to filter on only one of the above (such as class type) it worked but when I expanded it to 3 filter options it isn't working. It fails when no value is inserted in one of the options.
search_class.Hide
ActiveSheet.PivotTables("PivotSearchClass").PivotFields("class type").ClearAllFilters
If IsNull(Range("type_search").Value) Then
ActiveSheet.PivotTables("PivotSearchClass").PivotFields("class type").CurrentPage = "(All)"
Else: ActiveSheet.PivotTables("PivotSearchClass").PivotFields("class type").CurrentPage = Range("type_search").Value
End If
type_box = "pick a class type"
ActiveSheet.PivotTables("PivotSearchClass").PivotFields("group age").ClearAllFilters
If IsNull(Range("target_search").Value) Then
ActiveSheet.PivotTables("PivotSearchClass").PivotFields("group age").CurrentPage = "(All)"
Else: ActiveSheet.PivotTables("PivotSearchClass").PivotFields("group age").CurrentPage = Range("target_search").Value
End If
target_box = "pick a group age"
ActiveSheet.PivotTables("PivotSearchClass").PivotFields("school year").ClearAllFilters
If IsNull(Range("year_search").Value) Then
ActiveSheet.PivotTables("PivotSearchClass").PivotFields("school year").CurrentPage = "(All)"
Else:
ActiveSheet.PivotTables("PivotSearchClass").PivotFields("school year").CurrentPage = Range("year_search").Value
End If
year_search_box = "pick a school year"
ActiveSheet.PivotTables("PivotSearchClass").PivotCache.Refresh
Does anyone know ehat the problem is and how to fix it?
I think it will work if you change your tests to either:
If IsEmpty(Range("type_search").Value)
or
If Range("type_search").Value = ""
IsNull is used to test whether a variant variable contains a null value, which won't be true with either a blank or filled cell.
I don't have Excel on this computer and pivot tables are my weakness but I'll try to help since you seem alone on this. First make sure your script is indeed running the "True" case of your if statement and then I would edit the value of CurrentPage to see if your issue is there (i.e., change the "(all)" value to something else). Where does the error lie and what is the error description?

Using multiple values field in Lotus Notes

I am trying to write a logging system for a form in Lotus Notes but I am at the part where I am not sure how I can append the information about the fields that are changed in the log fields. There are 3 fields that I use Log_Date (date), Log_User and Log_Actions (Text, allow multiple values).
I thought if I add comma to the log field it will create a new line when displaying the form but I am still getting a type mismatch on the case 2 line.
How can I append the new values to the log fields?
Sub Querysave(Source As Notesuidocument, Continue As Variant)
' Compare the values in the form after it is saved with its original values when the document is not a new document.
Dim doc As NotesDocument
Set doc = Source.Document
Dim session As New NotesSession
Dim user As String
user = session.CommonUserName
If newDoc Then
doc.Log_Date = Now()
doc.Log_User = user
doc.Log_Actions = "New document created."
Else
' Load fields value to the array
lastValues(0) = doc.QCR_No(0)
lastValues(1) = doc.QCR_Mobile_Item_No(0)
lastValues(2) = doc.QCR_Qty(0)
' Compared each value in the array to see if there is any difference
Dim i As Integer
For i = 0 To 2
If lastValues(i) <> originalValues(i) Then
Select Case i
Case 2 : doc.Log_Actions = doc.Log_Actions & "," & "Field QCR_Qty is changed"
End Select
End If
Next
End If
End Sub
doc.Log_Actions returns the notesitem. To access the value you need to use doc.Log_Actions(0)
In LotusScript back-end classes (e.g. NotesDocument, NotesItem), a multi-valued field is represented by an array with one value per element of the array. For setting the value of a field, doc.Log_Actions is shorthand (they call it 'extended syntax' in the Domino Designer help) for assigning the first (i.e., zero subscript) element of the array, but that does not work for getting the value. To get the first value, you have to use doc.Log_Actions(0). To get or set the second value, you have to use doc.Log_Actions(1).
So, your Case 2 code could look like this:
doc.Log_Actions(1) = "Field QCR_Qty is changed"
My guess, however, is that you really want to be able to continually append to the end of the list of values each time this code runs. You are also going to want your code to be robust and not blow up on you if (for any reason!) the Log_Actions item does not exist in the document. For that, you are going to want to do this:
dim actionsItem as NotesItem
if doc.hasItem("Log_Actions") then
set actionsItem = doc.getFirstItem("Log_Actions")
call actionsItem.AppendToTextList("Field QCR_Qty is changed")
end if
Or,
If (Not doc.HasItem("LogActions")) Then
doc.LogActions = "Field QCR_Qty is changed"
Else
doc.LogActions = ArrayAppend(doc.LogActions,"Field QCR_Qty is changed")
End If
This is equivalent to the NotesItem method by rhsatrhs, which you use is matter of preference.

Resources