I have an MS Access database that has been upgraded over the years to 2016. I’ve been tasked with converting the data & system into a Sql Server database & Windows forms (C#). Most of the original text in MS Access is rich text. I have been able to read the data out of access & store it in Sql Server no problem. But when I read it out of Sql Server and try to load it into a RichTextBox it generates a “File format is not valid” error. The line of code that is problematic is:
rtb.Rtf = dr["req_sum_desc"].ToString().Trim();
Of course if I use the .Text property it sees the mark up tags as part of the string. When I look at what was originally stored as rich text in MS Access it looks more like HTML. Here is the beginning of a sample:
<div><font face=Arial size=2>Request for 68 FTEs, 25 faculty and 43 staff,
E&G funded</font></div><div> </div><div><font face=Arial
size=2>Instruction </font></div><div><font face=Arial size=2>Faculty
hiring has increased to address enrollment growth to meet student demand
for courses to shorten time to graduate.   .....
I've tried using a webbrowser control & the clipboard to convert it to a richtext string ...
WebBrowser web = new WebBrowser();
web.DocumentText = dr["req_sum_desc"].ToString().Trim();
web.Document.ExecCommand("SelectAll", false, null);
web.Document.ExecCommand("Copy", false, null);
rtb.Paste();
But that just gave me the field in the DocumentText rather than the contents of the field (really weird).
I've been looking for a windows control that can handle both HTML & RTF.
Does anyone have any ideas or solutions?
Related
We've recently upgraded some PCs and have subsequently come across some issues with the VBA code in an Access frontend we use to perform operations on a MySQL database. The specific piece of code pulls a serial number from the database and then prints it to a Dymo Labelwriter 450 as a barcode.
Style = vbExclamation + vbYesNo
Title = "Print Label For " & Me.txt_Barcode & " ?"
Response = MsgBox("Do you want to print a label for serial number " & Me.txt_Barcode, Style, Title)
If Response = vbYes Then
Dim myDymo As Object
Dim myLabel As Object
'On Error Resume Next
Set myDymo = CreateObject("Dymo.DymoAddIn") '
Set myLabel = CreateObject("Dymo.DymoLabels")
If (myDymo Is Nothing) Or (myLabel Is Nothing) Then
MsgBox "Unable to create OLE objects"
Exit Sub
End If
The code now breaks at line 8, i.e.
Set myDymo = CreateObject("Dymo.DymoAddIn") '
The error code I was getting was relating to ActiveX (which seemed possible that it might relate to going from 32-bit to 64-bit), but since installing the latest DLS from Dymo (DLS8Setup.8.2.2.996), it seems to have evolved to the following:
Run-time error '-2147467261 (80004003)
Automation error
Invalid pointer
I'm hoping someone can point me to an easy fix so I don't have to totally re-write the code!
Thanks in advance!
I managed to resolve this one in a couple of steps and to be honest, I'm not sure which exactly fixed this specific part of the problem:
First was to run the DYMO_Label_v.8_SDK_Installer
I also switched from the latest Dymo Connect to DYMO Label v.8
I then had to ensure the Barcode font we're using was installed as an admin for all users, rather than just a specific user profile
and finally, and I think this may have been the kicker, the software was looking for a label template called 'Serial.label' which I found on our server and copied and pasted into the C: drive where the software was looking for it.
I'm just glad I didn't have to re-write the code!
I am writting a test code in access 2007 (VBA) that would test the data and report if any record has problem.
It would do it by checking data with external data, so I am not using any of the access reporting tools.
This is an internal tools and will be used only by me, so the UI is not that important.
What I am doing is to write a VBA code that read recordset and external data and check the recordset.
I can do this, but I need a way to print this on UI. Something such as this:
Record no 10 is not valid : reason XXXX
Record 15 is not valid: reason YYYY
I was thinking of using a multi line text box to output this on screen, but I have several problem:
I can not find any way to make a text box as a multi line text box. There is no multi line propertyso I can output a line break.
If the size of recordset is big and there are a lot of errors, I am getting error that the size pro text proprty is too big.
What control should I use? I was thinking about using a label control, but I'm not sure if it's possible.
The easiest way is to use Debug.Print (output goes to the Immediate window -> Ctrl+g).
An Access text box that is large enough is always multi-line capable, there is no special property for that. Just append vbCrLf to each line to create a line break.
Me.txtLog = Me.txtLog & strError & vbCrLf
But for really long text output, a log file is the best option.
To write text files: either use FileSystemObject or the old fashioned Open statement.
The UserForm control in VBA has a MultiLine property, which you can set to True.
The other property is the EnterKeyBehavior that needs to be set to True to allow line breaks.
Alternately yes, you could use a Label control to achieve the same and even format it to look like a TextBox if you care.
But if long string of data, I would consider outputing it straight to a file with Open and For Output or For Append.
anyone could help me to programatically change only connection string of crystal report. I already designed a report using basic drag n drop method from report desinger wizard with already bind with fields with the right panel tool that has already connected using ODBC wizard connecting wizard from there..
all i want is i can code that a connection string can be change but the fields binding are same. this scenario may use in my system that can easily be move to other computer and connect to database with the same database.. it's like dynamic connection string but still the drag n drop bindings still on connected with the new connection string.. same database..
I use MySQL Database , VB.NET 2010, Crystal Report for VB.Net 2010
Thank You..
I am not sure that I can help you.
What I am doing is that I fill a datatable and apply it to the crystal Report.
My example is kind of different, since I upload the rpt file dynamically.
Dim cryRpt As New ReportDocument
Dim strReportPath As String = Me.selectedNode.RptLocation & "\" & Me.selectedNode.ReportFile 'The path for the rpt file
cryRpt.Load(strReportPath)
cryRpt.SetDataSource(crData) 'crData is the datatable that I am filling with data corresponding to the fields for the Crystal Report.
crvReport.ReportSource = cryRpt 'crvReport is a CrystalReportViewer)
crvReport.Zoom(2) ' use 1 for page width, or 2 for full page
I know that I am not helping you 100% but maybe you can find my answer as a little help.
Sorry I don't have time to recreate your problem and try to solve it.
This is about a legacy Access 2003 database that I've inherited. There's some code that links an Excel (97-2003) spreadsheet:
tdf.Connect = "Excel 5.0;HDR=Yes;IMEX=2;DATABASE="&strXLFileName
tdf.SourceTableName = strSourceTableName & "$"
CurrentDb.TableDefs.Append tdf
When I open the linked table afterwards, I see #Num! in place of numeric values in a column that is supposed to contain both numeric and text.
For example, in Excel:
Field1
H88
234
X65
432
Linked table in Access:
Field1
H88
#Num!
X65
#Num!
I've tried the following:(a) changing Excel 5.0 to Excel 8.0, which is more accurate for the format the soruce files are in; (b) importing using DoCmd.TransferSpreadsheet instead of linking.
The first still gives #Num!, while importing gives nulls.
Upgrading to later versions is not an option at the moment - there are a number of places within the code that use things that Application.FileSearch that require careful rewriting and testing.
Anyone know how to get Access 2003 to treat the "numbers" like they were text, too?
TIA!
Change IMEX=2 to IMEX=1 to treat all the values as text.
You can read more about IMEX at Connection strings for Excel 2007.
I inherited a huge, bulky MS Access database and am assigned to solve a problem in it. The problem is as follow...
System A exports its data to a pipeline-delimited .txt file. The files has special characters working correctly, for example the value "Müller" shows when opening this file in notepad or Excel.
Next, the Access DB imports the .txt file and stores the result in an internal employees table. The last name field is of data type "memo". The method to import data from the .txt file to MS Access is as follow:
Call DoCmd.TransferText(acImportDelim, _
"tblEmployees", _
"tblEmployees", _
me.txtImportFile, _
True)
After running this import and viewing the employees table I noticed that names with special characters are screwed up. "Müller" becomes "M├⌐ller" for example. I investigated some online help and found out that can include a "codepage" parameter in the TransferText call, so I set it to 65001 (which appearantly is the codepage for unicode):
Call DoCmd.TransferText(acImportDelim, _
"tblEmployees", _
"tblEmployees", _
me.txtImportFile, _
True, _
, _
65001)
Now that I have ran the import script again, I see no difference whatsoever, the special characters are still misformed. I'm running out of steam so I hope one of you has some advise on how to resolve this...
Both versions of your TransferText operation are using a SpecificationName named tblEmployees. What Code Page is specified in that Specification?
Try importing the text file manually. Choose "Advanced" from the Import Text Wizard. Then select Unicode in the Code Page list box. You may need to test with different Code Page selections until you find which one imports your text correctly.
Which ever Code Page selection works, save your choices as a specification and use it in your TransferText command, without supplying a separate CodePage parameter.
Using CodePage=1200 (msoEncodingUnicodeLittleEndian) solved the issue in my case.
there is an unicode list to use in VBA:
http://msdn.microsoft.com/en-us/library/office/aa432511(v=office.12).aspx