Summary: web page has a few fields to allow the user to enter payments. After the system processes the payments, the fields weren't cleared out. So my task is to simply clear them out. This is the few lines of code:
' first insert the transaction
InsertANewTransaction()
'clear out the values
txtAddTransAmount.Text = ""
ddlAddTransTypes.SelectedIndex = -1
txtComment.Text = ""
' then create and print the receipt
Payment2MsWordDoc(Payment, PaymentType, PreviousBalance, NewBalance, DueDate, ProjMinPayment)
I added the three lines in the middle resetting the values. Problem is, they don't reset. Doing some debugging the file lines of the Payment2MsWordDoc procedure are the culprit:
Response.AppendHeader("Content-Type", "application/msword")
Response.AppendHeader("Content-disposition", "attachment; filename=" + fileName)
Response.Write(strBody)
The procedure is writing an HTML receipt into the strBody and displaying it to the user. They see the 'File download, do you want to open or save this file....' and can open the receipt in ms-word. Without those three lines, the resetting works. So clearly they are messing up something, I just don't understand what.
I've got a workaround, but I'd like to know what is going on. Even to the tune of is this a correct way of creating/downloading a document. This in an inherited system, the original designer is long gone. I'm not strong in either VB or web apps so am clueless as to what the problem is.
Imagine you have a textarea on a webpage and then a regular hyperlink to a word document below that. If you type into the textarea and then click the link, do you expect the textarea to clear out? No, the browser will just launch the word document and leave the page as is. The same thing is happening with your form. Upon submit, the server is just sending a word document and since the server hasn't sent any new HTML the browser just stays as is. All of your clearing out of textfields doesn't matter because the new state is never sent down the wire. What you need to do is to send the browser new HTML and not the word doc. In the new HTML you can include a meta redirect to the word doc or better yet a download link.
Related
I know there are other threads on this, but I've tried to implement the suggestions without success.
SHORT VERSION: I am trying to browse to a file and add its path, filename, extension into a field. I'm using a form as a dialog box with the usual wizard code. I use a module with browseto to collect and format the data. 95% of the time it works, the other, still a sizable amount with the size of my db, doesn't write the selected filename back into the linked field. If I open the form again, the selected filename is there and I can copy-and-paste the info into the field.
I thought that I could (yes, a bandaid) write the data directly to the field from vba and bypass the problem, but now I have the dreaded record edited by another user error.
I tried Me.Refresh and if Me.Dirty SaveRecord in various places and a variety of permutations and I can't.
If I can write the normalised path\filename\extension data into the field from VBA I will never care about the original problem because I have now realised that I can save a lot of entry time if I update three (3) fields over two (2) subforms with pieces of what the browseto returns.
I thought of losing the dialog/form, but it is looking up and displaying contextual information that helps with the business of using the data.
CONTEXT: I have a catalogue of everything books, release media, DVDs, downloads, rips, including media kits with soundbites, trailers etc. Thirty+ years of a professional reviewer's materials, to which I still occasionally need to refer. I have a highly normalised database flexible enough to retain integrity despite system upgrades, upgrading to new servers, changing overall storage, changes to drive and path locations, etc. My app is completely table-based, no picklists or options that are not filled by forms with help notes. If I double click on the filename of a soundbite, for example, the app opens the file with the best player I currently have for that file (same for PDF, CBR, DOC, JPG etc). If I change apps, there's a newer version name, etc I change the table linking the app to that item format. I don't have to touch the code.
Standard wizard code to open dialog
DoCmd.OpenForm stDocName, , , stLinkCriteria
In this snippet [LocationDigitalMedia] is the field on the browseto form.
'===If file selected
If strFilename <> "" Then
strFilename = Replace(strFilename, stDigitalLocation, "")
[LocationDigitalMedia] = strFilename
Else
MsgBox ("nothing selected, click Make Playlist to create a new MSU or try again")
End If
I tried adding this and got the save record error
'Update fields in catalogue_tracks_subform
Forms!AboveCatalogueEntries!catalogue_tracks_subform![TrackDigitalAddress] = Forms!Browse2TrackFile![LocationDigitalMedia]
I tried forcing the subform to save before I opened the dialog, I tried having the open event save the record, I'm guessing that somehow I need to close the original record, get the data in vba and update it from there. Is the linkcriteria keeping the record active?
Every day our Helpdesk has to send out a report. That report needs to link to a website that displays that days statistics.
Example URL:
http://hostname/dashboardname/date
Which would look like this:
http://hostname/HelpdeskTickets/2015-03-18
Heres what I've tried:
First I looked into field code values and doing something like this
{HYPERLINK "http://hostname/HelpdeskTickets/{DATE \# "yyyy-MM-dd"}"}
And this works, until you close the outlook message. If you don't have F9 to update the field code, and save and close the .msg file it will disappear leaving just the blank link without a date. If you hit F9 before closing it, it puts that days date into the field, however when you close and save it the field code disappears and leaves the date in place of the date field code. Also I noticed this problem doesn't happen in word. You can save and close a word file and it keeps the field codes.
Another thing I've tried is to use VBA to edit the links in the message body. So far nothing has actually worked.
The only thing that partially worked was taking the body of the document and using a string replace function on it. However this destroys all formatting and hyperlinks along with it.
I'm open to any ideas on how this can be achieved.
My main problem is that the people at the helpdesk can't seem to use anything that isn't fool proof. So having them press F9 before sending this email was actually scaring people that they wouldn't be able to do that.
You can use VBA to edit the message body programmatically. It is not clear what code you used earlier, but the main ways are described below:
HTMLBody - a string representing the HTML body of the specified item. The HTMLBody property should be an HTML syntax string.
The Word editor. The WordEditor property of the Inspector class returns an instance of the Document class from the Word object model. So, the message body is represented by the Word Document.
You can read more about all possible ways in the Chapter 17: Working with Item Bodies.
I have a win-form application that generates passwords that I would like to send directly over to a web page textbox like input as apart of a new user sign up. I found a similair question. (Fill Form C# & Post Error) But I dont think I am after the same goal. Is it possible to do this without using a macro or manually copy n pasting? The above post is in C# however I will ever using vb. If there is a answer on here please link, but I have gone through the forum.
I'm currently using Word documents as templates where blanks have to be filled dynamically/programmatically in PwoerBuilder.
This has always worked fine until the company moves on Windows 7.
In short, the Word application is opened and made invisible.
Word.Application.Visible = false
Except that sometimes, and I don't know why, once the template is accessed, Word opens itself just as if I had double-clicked the template byself through the Explorer - but I didn't.
So, it asks whether I want to open it in read-only mode, since the application already has a handle on the file. And even if I click [Cancel] not to open the file, Word opens with no document, then the application crashes.
It reports PowerBuilder System Error 35.
Error Number 35.
Error text = Error calling external object function open at line 24 in function of_fusion of object n_cst_9999.
The external object that the application is trying to call a function against is Word.
oleobject lole_word
lole_word = create oleobject
lole_word = ConnectToNewObject("Word.Application")
lole_word.Documents.Open("templatefile.docx")
It may work for a few documents, and after a few, the problem comes up. This is the first time ever I meet with this issue.
I'll be glad to answer anyone's question who's trying to help.
Will, you may try setting DisplayAlerts and FeatureInstall properties on Word Application object.
That hid most of word alerts for us. (The code is from C# project and may not be exactly what you need)
Word.Application.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone;
Word.Application.FeatureInstall = 0;
You may also try making a copy of the file before opening it to avoid accessing same .docx from different threads - if that may be the case.
I have an application who have multiple files .rtf i open it on a rich text box, but im having an issue
here is my code for print preview
PrintPreviewDialog1.Document = PrintDocument1
PrintPreviewDialog1.ShowDialog()
i press the button for preview and it shows me the preview.
but if i change the content of the rich text box with another file, the print preview shows me empty
any idea how i can send it to a new preview?
Looks like you've fallen in the pitfall of Magic Coding: where you just implement code, without exactly knowing what's going on in the API. There's very little information to go on, but first thing I would recommend is using the Debugger: set breakpoints to see exactly what data is being handled.
Apperently, data containing Nothing is being sent to the printpreview, thus the PrintDocument1 must be empty. I'd recommend not re-using the objects, but to reinstantiate them. So start with PrintPreviewDialog1 = new PrintPreviewDialog, setting it's settings, etc. Basically, follow any tutorial on Printing in VB.Net and make sure you re-instantiate the objects you're using.