I am attempting to export out a concatenated note from a table in a database I'm given and export it out into a CSV file. The below code works getting it to be seen in the Datasheet view. However whenever I export the file to a CSV the Note column is cut off at "Actual Note:" and CnNote_1.CnNote_1_Actual_Notes is not displayed. I'm not sure what could cause this and would like help figuring it out.
One potential thing to consider is that CnNote_1.CnNote_1_Actual_Notes is a long text field while all other fields, except the two date fields, are short text fields. I don't know if that's causing it though.
My only other guess is there a hidden character in the beginning of the Actual Note.
I'd greatly appreciate any insight as to why it might be dropping.
SELECT CnBio.CnBio_Import_ID,
CnBio.CnBio_First_Name,
CnBio.CnBio_Last_Name,
CnBio.CnBio_Org_Name,
CnNote_1.CnNote_1_Type AS [Note Type],
Format(CnNote_1.[CnNote_1_Date], 'yyyy-mm-dd') AS [Date],
Format(CnNote_1.[CnNote_1_DateAdded], 'yyyy-mm-dd') AS [Original Date],
IIf(CnNote_1.CnNote_1_Title <> '', "Title: " & CnNote_1.CnNote_1_Title & " ") & IIf(CnNote_1.CnNote_1_Description <> '', "Description: " & CnNote_1.CnNote_1_Description & " ") & IIf(CnNote_1.CnNote_1_Actual_Notes <> '', "Actual Note: " & replace(replace(CnNote_1.CnNote_1_Actual_Notes, Chr(13), " "), Chr(10), " ")) AS Notes
FROM (Cn LEFT JOIN CnBio ON Cn.CnBio_LINK = CnBio.CnBio_LINK) LEFT JOIN CnNote_1 ON Cn.CnNote_1_LINK = CnNote_1.CnNote_1_LINK
For more information I'm exporting via MS Access's export using the Text File export. It also occures when exporting out using the Excel unless I select "Export out with formatting and layout."
I am not sure if that is the only problem but you are using IIF wrong.
Instead of
IIf(CnNote_1.CnNote_1_Title <> '', "Title: " & CnNote_1.CnNote_1_Title & " ")
Use
IIf(CnNote_1.CnNote_1_Title <> '', "Title: " & CnNote_1.CnNote_1_Title & " ", "")
All of your IIFs are similarly flawed.
Related
The DLookup is returning number values as text. Thoughts on what's either wrong with my code or reasons why that would happen? I'm hoping it's something simple.
Sort: DLookUp("Sort","contacts_rank_CurrentRank","ContactID = " & [ID])
I've tried to Format as "General Number" but that doesn't transform the value back to a number
I've tried the below formula but that results in "Error"
Sort: DLookUp("Sort","contacts_rank_CurrentRank","ContactID = '" & [ID] & " ' ")
Visual of the data in the query I'm looking up the data from. Sort Column in Contacts_Rank_CurrentRank
Value that is being returned with the dlookup
You don't really need a dlookup here - a sql left join against that table will run at least 100x times faster.
But, you can do this if performance is not a issue:
clng(DLookUp("Sort","contacts_rank_CurrentRank","ContactID = '" & [ID] & " ' "))
So I have a bunch of tables all linked together someway or another, and I'm trying to make a report that lists all the items in a selected range of invoice numbers, and to begin the process, the User will click a button, and that button will open a pop up form with 3 fields, FirstInvoiceNumber, LastInvoiceNumber, and Client. These fields than save what the user enters as globals which are then plugged into the SQL statement in the Report_Open Event. There was a syntax error, but after about half an hour I found and fixed it. but now, I'm getting this Run-time Error 2465, which says "Microsoft Access can't find the field 'l1' (In front of the 1, its a symbol I don't know how to type, but it looks like a tall lowercase L) referred to in your expression."
Maybe I'm just looking at this for too long, but the only "1" I can see, is where the SQL statement has the Initials field, and both of them are inside parenthesis, so I'm not sure whats wrong. Anyways, here is this ridiculous SQL
(Note: I find it easier to read on one line and just scroll sideways rather than having a big chunk split onto multiple lines, so this SQL statement is fit onto only 2 lines, I'll put an extra paragraph space so it's easier to find it)
Me.RecordSource = "SELECT Invoices.InvNo,
Invoices.JobNo,
Invoices.InvDate,
Invoices.TimeTotal,
Invoices.Tax,
Invoices.POTotal,
Invoices.SubTotal,
Invoices.InvTotal,
Invoices.DatePaid,
Invoices.AmountPaid,
Invoices.Terms,
Contacts.EMail,
Invoices.Status,
' & 'Attn: ' & [FirstName] & ' ' & [LastName] & ' AS FullName,
Companies.CompanyFullName,
Companies.CompanyAbrv,
Contacts.Department,
' & [City] & ',
' & [State] & ' ' & [Zipcode] & ' AS AddressLine3,
Invoices.ClientPONo,
InvLineItems.LineItemNote,
InvLineItems.Adjustments,
InvLineItems.Status,
InvLineItems.Cost,
[Cost]+([Cost]*[Adjustments]) AS AAC,
' & [Contacts].[AddressLine1] & ',
' & [Contacts].[AddressLine2] & ' AS AddressLine1and2,
' & [Invoices].[InvNo] & '-' & [Invoices].[JobNo] & ' AS InvNoandJobNo,
Left([Contacts].[FirstName],
1) & Left([Contacts].[LastName],
1) AS Initials,
Jobs.JobTitle,
& ' & [Jobs].[JobTitle] & ' ' & [Jobs].[ClientCode] & ' AS Product,
InvLineItems.Requester,
Companies.CompanyID' _
& 'FROM ((((Invoices
LEFT JOIN (Contacts
RIGHT JOIN Jobs ON Contacts.ContactID = Jobs.ContactID) ON Invoices.JobNo = Jobs.JobNo)
LEFT JOIN InvLineItems ON Invoices.InvNo = InvLineItems.InvNo)
LEFT JOIN PurchaseOrders ON Invoices.InvNo = PurchaseOrders.InvNo)
LEFT JOIN POLineItems ON PurchaseOrders.PONo = POLineItems.PONo)
LEFT JOIN Companies ON Jobs.CompanyID = Companies.CompanyID'
I have a table with 4 columns and update them through excel user form and all are varchar (255). when I try to enter the character ' I get syntax error, mysql doesn't accept it... What am I doing wrong here, do I need to change datatype
Update: I figured that the problem is not with MySQL (obviously :) ) but my code to update the table.
Dim sq As String
sq = "UPDATE sample.`nov-21` SET `Site work being carried out`='" & sitecombo.value & "',`Group`='" & eqgrp.value & "',`Description`='" & desc.value & "',`T Number`='" & tn.value & "', WHERE sample.`nov-21`.`ID`= " & Me.IDnum & ";"
Escape ' with \ or another ': 'O''Malley' or 'O\'Malley'
When you write 'O'Malley', MySQL read string literal 'O' followed by name Malley (which is not recognized) and a ' with no meaning, hence the syntax error.
I have 2 datasets from which I populate my report, ActiveProjects (primary dataset) & ActiveTasks. I use the expression:
=Join(lookUpset(Fields!Title.Value, Fields!Related_Project.Value, "" & Fields!Title.Value & "", "TeamTasks"), "<br> <br>")
This works great for retrieving each task grouped with its related project and it also includes a dynamic URL to the respective tasks.
My question is: Is it possible to include additional pieces of information (such as TargetDate - which is in the ActiveTasks Dataset) to be placed alongside the Task in the same Column & Row (Otherwise it wont remain aligned as the Task list goes on, since they are of varying length, while the date is not) ?
Ideally, it would return something like this:
Project Title Task Title
_______________|_________________
Project A | Task a 12/12/16
| Task b 02/12/16
| Task c 28/11/16
Project B | Task a 22/11/16
|
Thanks in advance and sorry if this has been addressed before!
Try:
=Join(
lookUpset(
Fields!Title.Value, Fields!Related_Project.Value,
"<a href = " & Chr(34) & "https://example" & Fields!ID.Value & Chr(34) &
">" & Fields!Title.Value & "</a>" & " " & Fields!TargetDate.Value , "TeamTasks"
),
"<br> <br>"
)
Also you may want to format your date, so you can use FORMAT(Fields!TargetDate.Value,"dd/MM/yyyy") inside a LookupSet function.
It is not tested but should work.
Let me know if this helps.
An example is trying to combine first name and last name into fullname from a table thats called employee. What expression do I type in the Control Source? I've typed FullName: [First] & " " & [Last] but it kept saying error.
=[First] & " " & [Last]
Should do it.
To avoid complications with nulls use:
=Nz([First], "") & " " & Nz([Last], "")