Remove unwanted characters from sharepoint user displayname in infopath - sharepoint-2010

I am populating infopath repeating table with sharepoint list item. In the list one of the column is "Approver"(PersonOrGroup) type. While I am displaying this column(Display Name) in infopath repeating table, I am getting the below value:
LastName,, FirstName,#,#,#
I want to remove unwanted characters from the display name and want to display in below format:
LastName, FirstName ;
How can I do this?

Try this:
concat(substring-before(field1, ","), ",", " ", substring-before(substring(field1, string-length(substring-before(field1, ",")) + 3), ","), " ", ";")
The +3 there is the count of two commas(,) and 1 space.
example is:
Doe,, John,#,#,#
RESULT:
Doe, John ;

Related

Textbox without spaces in between

I have this SQL table where there are 6 address fields ...
Address 1
Address 2
Address 3
Address 4
Address 5
Address 6
I have to club all the address fields into one text box in ssrs. So that the whole address is displayed in the same text box field.
Plus the condition in the requirement is in the pic below.
Display the address lines one below the other in the repor. If any field is empty skip and display the next field. Don't leave the space
I tried using (iif statements) ...but this doesn't seem to help ... Somewhere or the other there were gaps in the text box ..
Fields!address1.values & vbcrlf + Iif(isnothing(fields!address2.values = "",fields!address3,fields!address2.values) Iif(isnothing(fields!address3.values = "",fields!address3,fields!address3.values) Iif(isnothing(fields!address4values = "",fields!address3,fields!address4.values) ....
This would actually likely be easier in the SQL layer. Then you can just use CONCAT_WS:
CONCAT_WS(' ',Address1, Address2, Address3) AS FullAddress
If you need to use an expression would something in this form work ?
iif(isnothing(Fields!address1.values,"", Fields!address1.values & vbcrlf) &
iif(isnothing(Fields!address2.values,"", Fields!address2.values & vbcrlf) ... etc.

Visual Basic - Multicolumn listbox and adding items

So here's the thing; I'm making this home-made sign-up thing for a school project.
I've got first name, last name, date of birth, SS number among other things.
I can send data to another form's listbox
Dim SSID = (tx_SSP.Text)
Datbase_of_User_Information.ListBox1.Items.Add(SSID)
However this will only add ONE item to the listbox. I know there's a way to add in a multi-column data thing into the list
ex:
SSID | Fname | Lname | DoB
Something like the above.
But I've tried doing Listbox1.AddItem("row1 col1", SSID)
and it didn't work.
I had this same problem and I kind of cheated by just putting all the values together into one string and using tabs.
Listbox1.Items.Add(SSID & " " & Fname & " " & Lname & " " & DoB)
I've heard a better solution would be to use a ListView if you want a true multi-column solution.

Insert data from a form into a table [duplicate]

This question already has an answer here:
Inserting data from a form into a table
(1 answer)
Closed 7 years ago.
It's been probably 3 years since I have had to use VB or VBA code. I am working on a project for work using Microsoft Access where I need to take the information that is listed on the form and insert it into a table. What I am stuck on is the last part of the code the values part. This is what I have so far.
INSERT Volunteers (Name, Email, Number, Emergency Contact, Emergency Number) VALUES (and this is where I get stuck)
Thank you all in advance!
You want the single-record table append query:
INSERT INTO Volunteers (Name, Email, Number, Emergency Contact, Emergency Number)
VALUES ("Value1", "Value2", "Value3", "Value4", "Value5")
Assuming you are constructing the SQL statement in the code-behind of the form, you can access the controls by name:
Dim sql As String
sql = _
"INSERT INTO Volunteers (Name, Email, Number, Emergency Contact, Emergency Number) " & _
"VALUES (""" & txbName & """, """ & txbEmail & """, """ & txbNumber & """, """ & txbEmergencyContact & """, """ & txbEmergencyNumber & ")"
(All those triple-quotes are to get a double-quote (") into the final SQL statement, for text fields; numeric fields don't need any delimiter, and date fields use the # as a delimiter.)
If you are adding values from a different form, you can access them like so:
Forms!OtherForm!ControlName
and values in a subform (IIRC):
SubformControl.Form!ControlName
See here for more details.

Referencing data held in an Access Database with Visual Basic

My project is a small Access database with two tables. The first table is "EMPLOYEES" and the second table is "TOOLS". The database keeps track of what specific tools each employee has in his/her possession. My Visual Basic form adds and deletes employees from the database via the dataset.
What I would like to do is set a variable to hold the Employees full name taken from two different fields. (The "FirstName" field and the "LastName" field)
How do I reference (or get the value of) the "FIRST_NAME" and "LAST_NAME" data stored in the "EMPLOYEE" table so that I can set my Visual Basic string Variable with those two values.
Is this a job for SQL?
Something like this:
For i As int32 = 0 To myDATABASE.EMPLOYEES.column.Length
Dim fullName As String = _
myDATABASE.EMPLOYEES.row(i).FIRST_NAME _
& " " & _
MyDATABASE.EMPLOYEES.row(i).LAST_NAME
mylistBox.add("The full name is: " & fullName)
Next
If you are trying to populate a listbox with names, then you can set the recordsource to something like:
Select [First_Name] & " " & [Last_Name] as FullName from Employees
You can concatenate the names in sql as Wayne G. Dunn suggests or you can also do it in vb like this:
For i As Int32 = 0 To MyDATABASE.Tables("EMPLOYEES").Rows.Count - 1
Dim fullName As String = _
MyDATABASE.Tables("EMPLOYEES").Rows(i).Item("FIRST_NAME").ToString() _
& " " & _
MyDATABASE.Tables("EMPLOYEES").Rows(i).Item("LAST_NAME").ToString()
mylistBox.add("The full name is: " & fullName)
Next
For something as simple as putting two strings together it's really a matter of personal preference and it's good to know both ways.

VB.NET -> SQL Exporting String "901-0656" to not be 245 (901 minus 656)

I am trying to add new records to a Access database through VB.NET. The table "Quantities" has three columns:
PartNumber (string), PadsPerStrip (integer), and Verified (boolean)
The format that we use for PartNumber is ###-####-### (ie 901-0656-000). When I run my code everything is added correctly but math is performed on Part number so that the - is treated as a minus sign even though it is a string. Here is my sql command:
cmdInsert.CommandText = "INSERT INTO Quantities (PartNumber, PadsPerStrip, Verified) VALUES ( " & partNum & ", " & updatingPPS.ToString() & ", No);"
When viewing the command in a MsgBox it shows up as:
INSERT INTO Quantities (PartNumber, PadsPerStrip, Verified) VALUES (901-0656-000, 3, No);
Is there a way to make it skip the math operator when exporting the part number?
Make sure to enclose the part number with quotes. Without that, the value is not considered as a string when run in the database.