Google Calendar API attendees VB - vb.net

I'm trying to use VB to post to the console the name of an event, the start date, and the displayname or email of the attendees for that event.
But I can't seem to get it to display.
Please help!
This is what I have tried which seems logical but doesn't work :(
Console.WriteLine(calendarEvent1.Summary & ". Start date: " & CalendarEvent1.Start.DateTime.ToString() & ". Assigned to: " & calendarEvent1.Attendees.displayName)

.Attendees returns a list, so to return the name of the first attendee, you would use this line instead.
Console.WriteLine(calendarEvent1.Summary & ". Start date: " & CalendarEvent1.Start.DateTime.ToString() & ". Assigned to: " & calendarEvent1.Attendees(0).DisplayName
If you want to list all the attendees, then you would need to iterate over the list in exactly the same way as you do in VB.Net lists.

Related

Microsoft Access - Using a form to input data into a different table with VBA?

Trying to use a form named 'Customer Entry', that when clicked, enters the data that has been typed in said form into a table that is named 'CustomerRecord'. I keep getting errors and am at my wits end. Here is my code below, this is in VBA.
Public Sub Command19_Click()
CurrentDb.Execute "INSERT INTO CustomerRecord(Customer Name, APM, UAID, Context Code, Purpose Code, Context Description, Purpose Description) " & _
" VALUES (" & Me.txtCustomer Name & ", " & Me.txtAPM & ", " & Me.txtUAID & ", " & Me.txtContextCode & "," & Me.txtPurposeCode & ", " & Me.txtContext Description & ", " & Me.txtPurpose Description & ")"
frmCustomer
Entry.Form.Requery
End Sub
If you want to edit data from two tables on a single form you need to make an updatable query to base your form upon. Set your forms RecordSource property to be the updatable query. Now you can add form elements from the source that allow the user to edit all the fields directly.
See this list of pitfalls to ensure that your query is updatable:
http://allenbrowne.com/ser-61.html
If you absolutely must edit data elsewhere from your form, which you occasionally must do, don't use an SQL query execute statement to do so. Use a recordset object instead. This is both more secure, more reliable, and easier to read the code.
See this guide for an example of how it's done: https://learn.microsoft.com/en-us/office/vba/access/Concepts/Data-Access-Objects/modify-an-existing-record-in-a-dao-recordset
Additional reading: https://learn.microsoft.com/en-us/office/client-developer/access/desktop-database-reference/recordset-edit-method-dao

Problem with LIKE command on Visual Studio 2010 and Access, VB.NET

I have searched for answers but the ones I have found I can't get working.
I have a database written in MS Access located on a network drive. The front-end has been written in Visual Studio 2010 (VB). I can get the data OK but I need to do a LIKE search to see if there is any records that might match what the user has entered.
Essentially the database is a list of barcodes provided on media. Users provide a list of barcodes but this is done by eye and the last two letters / numbers can be missed, due to size, location or not provided. When scanning the barcode it reads the full details. For example 'AIF00511L6'.
If there is a duplicate then I need to inform the user that there might be one or more records. Duplicate barcodes are possible (don't ask), so I need to provide the details to the user so that they can make the final decision as to if this is the same or different media.
The code I have in VB is:
Dim SQLString as String = "SELECT COUNT(*) AS Count1 " &
"FROM " & Table & " " &
"WHERE " & Column & " " &
"LIKE '*" & Search & "*';"
The code at runtime SQLString is:
SELECT COUNT(*) AS Count1 FROM Assets WHERE aItem LIKE '*IF00511L*';
This works OK in Access (returns 1) but it's not working from VS. I have tried using the '%' in place of '*' but this is not working either. In VS it returns 0.
Any help on this would be appreciated.
I saved and restarted my project and made the below change and now it's working!
Dim SQLString As String = "SELECT COUNT(*) AS Count1 " &
"FROM " & Table & " " &
"WHERE " & Column & " " &
"LIKE '%" & Search & "%';"
So it needed to be a % and not *, something I tried and didn't work, Oh well.

Error 2465 in MS Access when running a VBA code

Read through a few of the previously asked posts about this error but still cannot understand it.
The error text is "Run-time error '2465' CASREP reporting tool can't find the field '|1' referred to in your expression
I have a form to assign parts to certain supply reports. We have a form where users can manually hyperlink the parts to the request if they fall in the cracks. There is a check box feature, followed by the use of an "Assign" button to achieve this.
Every time a box is checked and a user selects "Assign" the error pops up. The string of code that pops up with the bug is as follows:
strSQL_del = "DELETE FROM [tbl_Temp_Assign] " & _
"WHERE [jcn_cd]= '" & Forms![Parts: Assign Unit].[tblTemp_Assign subform1].Form.[jcn.cd] & "'
AND [CASREP #] = '" & strCASREP & "' AND [doc_num_cd] = '" & Forms![Parts: Assign Unit].[tblTemp_Assign subform1].Form.[doc_num_cd] & "'
AND [last_updated_dte] = #" & Forms![Parts: Assign Unit].[tblTemp_Assign subform1].Form.[last_updated_dte] & "#
AND [PMOMsgDte] = #" & Forms![Parts: Assign Unit].[tblTemp_Assign Unit].Form.[PMOMsgDte] & "#" 'Intentionally left off AssignDte
Any help is greatly appreciated. I'm lost on what is wrong.
The error is related to the SQL string concatenation, but that string is quite long, it's hard to say if you have a space between ' and the first AND condition. Also, after the first continuation character _, is all that a single line?
Anyway, I would strongly advise to setup a delete query where you pass the form values as parameters and in VBA you just execute the query. It will be easier to update later on if needed.
The query:
PARAMETERS [prmTextField] Text (50), [prmDateField] DateTime, [prmNumberField] Long;
DELETE *
FROM T
WHERE T.TextField = [prmTextField]
AND T.DateField = [prmDateField]
AND T.NumberField = [prmNumberField];
Then, in VBA just execute the query.
With CurrentDb().QueryDefs("QueryName")
.Parameters("[prmTextField]").Value = '[Value from Form (text)]
.Parameters("[prmDateField]").Value = '[Value from Form (date)]
.Parameters("[prmNumberField]").Value = '[Value from Form (number)]
.Execute dbFailOnError
End With
By the way, do you really need to pass all those parameters to delete a record? Usually, just the record id is needed.

Append query inserting string WITH special characters from user input

I have a database that I am building where users can add new records at will. The record has a client name which often contains " ' , . special characters. Whenever these appear, the append query bombs out. I know I can filter out these special characters to avoid this, but I don't want to do that if I can help it.
DoCmd.RunSQL ("INSERT INTO tblPlanSpecs ( PlanName ) SELECT '" & (NewPlan) & "'")
I want the user to click the "add new client" button, type in the client and plan names into the text boxes, and then click "add" and this new client/plan name will be added as a new record to the database, and the two text boxes will be populated with the correct client name and plan name. They need to contain the ' " , . etc because that really is the client's name. Is this possible?
Thank you.
You have to use escape characters like the following...
DoCmd.RunSQL "Insert Into tblPlanSpecs (PlanName) Values(" & Chr(34) & Replace([NewPlan], """", """""") & Chr(34) & ");"

Visual Studio 2012 - Add multiple items on same writeline

Okay, so what i"m doing is creating a word file with my application with my labels and textboxes to create a receipt. In my word file, I am trying to write what is in a first name label beside what is in a last name label.
Here is the code I have, but I just seem to be missing something, because the word file keeps putting a huge gap between the first name and last name. I'm sure it's a very simple fix, but Google doesn't seem to be helping with what I am trying to describe.
printFile.WriteLine("Name: " & vbTab & FirstNameTextBox.Text + LastNameTextBox.Text)
I assume it must be the vbTab keyword.
which is fixed and cannot be changed.
That said you can manage a workaround as follows:
Public Const MyTab = " "
and in your code
printFile.WriteLine("Name: " & MyTab & FirstNameTextBox.Text + LastNameTextBox.Text)