MS-Access VBA, how do you keep a textbox active after SetFocus and selecting the text? - textbox

The plan:
I have a single form with a text box that I type a serial number into. [intUID]
The subforms on this same form use this to query and display related information. After I typed a serial in, I needed to refresh to get the subforms to requery, see code below. This works fine. I then set focus back into the serial number text box, ready for the next entry. This also works fine.
The rub:
I want the text box to stay fully selected when I get focus set back to it. That way, when the next serial is entered, it deletes the old one. My code does this (can be seen stepping through the code) until the "End Sub" when it unselects it!
Private Sub intUID_AfterUpdate()
'Refresh sub forms
Forms![frmMain]![q_AG_CenterLines_X subform].Form.Requery
Forms![frmMain]![q_AG_CenterLines_Y subform].Form.Requery
'Set focus back on the barcode
Forms![frmMain]![txtSchedule].SetFocus
Forms![frmMain]![intUID].SetFocus
'Select all the text in [intUID]
Forms![frmMain]![intUID].SelStart = 0
Forms![frmMain]![intUID].SelLength = Len(Forms![frmMain]![intUID])
End Sub

Related

FDMemTable Loses FieldDefs information when there is AutoInc Field in Delphi

I am creating a memory table TFDMemTable for a delphi form, and define the fields under FieldDefs. After I am done with the definition of the fields manually, I go to the Fields Editor to add the fields that I just defined.
Everything works perfect until I have an AutoInc type field in my FDMemTable. I am using Delphi 10.3.2 version and I was wondering if I am missing anything or this is a IDE bug.
PS: I have done couple of tests, and I think that if the AutoInc field is not defined as the last field, everything disappears. I am not %100 sure of this case, but pretty much every time I try I loose the fields under FieldDefs.
Here is the steps:
Place a FDMemTable icon
Open FieldDefs window
Create a bunch of fields (string, integer ...)
define the names, types (and sizes for strings)
Open FieldsEditor
Add fields
until here everything works as they should.
Go back to fieldDefs window
create and name a new field with autoinc type
open the fields editor screen and add the last added field.
everything is still good to go as long as there is no more changes in the structure.
Here the weird thing happens if you do the following.
open FieldDefs window
create any field ( lets say integer type )
Go to Fields Editor window to add this last created field.
and you will see that you don't see this new field to add.
when you go back to fieldDefs window to see why it is not showing,
you will see all the previous and last added fields' definitions gone..
In order for me to go around this problem, I open the form in text form and insert the new field right before the last field which is autoinc,
add field editor entry manually in the text form,
and when everything is right, I toggle to form view.

How to create dynamic hyperlink using Field Codes in MS-Word?

I am trying to add a hyperlink to a field code in MS-Word, but I want the same field code to populate as part of a search query in the url. More relevant info below:
For Instance, this field code is linked to a form and will populate with a tracking number pulled from an inventory database «TrackingNumber», but then I want to link this generated tracking number into a url query is as follows:
HYPERLINK "https://www.google.com/searchq=«TrackingNumber»"
Is this even possible? And if so, how should I configure?
By default, if you insert a mailmerge field into a hyperlink field, the hyperlinks will all show the first record’s address as the 'Text to display' text, even though the hyperlinks will actually point to the merged targets.
Here's how you can do get a mailmerge to display your preferred default 'Text to display' text instead:
Disregarding mergefield issues for the moment, insert a hyperlink into the document in the normal way, choosing whatever 'Click Here' text you want in the 'Text to display' box.
Select the inserted hyperlink and press Shift-F9 to expose its field code.
Replace everything in the field between '=' and '"' with your «TrackingNumber» mergefield.
Select the field and press F9 to update the display.
In Word 2007 & later, you can make the display text variable also, by following these additional steps:
Position the cursor anywhere within the display text.
Insert a mergefield pointing to whatever data field you want to use for the display text (this could even be the «TrackingNumber» mergefield).
Delete all of the previous display text either side of your last-inserted mergefield (note that this field will likely have updated already).
Execute the merge.
After merging to a new document, use Ctrl-A, F9 to update all fields. Without this, the mergefield hover text won’t update to the correct targets.
Note 1: The above is only for merged output sent to a new document; it does not work with merges to email or print. For merges to email, see: https://support.microsoft.com/en-us/kb/912679
Note 2: Hyperlink fields modified this way are liable to cease functioning once the merge has been executed. Accordingly, it's best to save mailmerge main document before doing the merge and not re-save it afterwards. If you need to make changes to the mailmerge main document, don't make/save them after doing a merge; make/save them beforehand.

Devexpress : Express Printing System - Print contents of 2 cxgrid's

Actually, I never tried this but it's supposed to work judging from some comments I've read. I have two grids: One displays Hotel guests and the other one their former stays (Date from- date to, etc..). Now I would like to be able to print both contents as a single report.How do I add the linked contents of the second grid to my dxComponentPrinter1Link1 ??
In the IDE open your form.
Right click and choose ReportLinks on the TdxComponentPrinter
object.
In the links editor window, instead of clicking the Add button, click the dropdown arrow next to the Add button. Choose Add Composition.
This creates a TdxCompositionReportLink object. There is an Items property which will hold all of the report links you want in the composite report. This will print out as a single report. I can't promise both reports will be on the same page though. I've never figured out how to do that.

run SPD workflow on changes to any field EXCEPT one?

I have a custom list. Each item in the list has 39 fields/columns that need to be filled out and a 40th field that gets filled out by a separate workflow.
I have another workflow that I need to trigger if any of the fields change EXCEPT for one.
Why? Because that field has a custom ID# in it and that field gets populated AFTER the form is submitted. Therefore, there will ALWAYS be a change in the list item. Thus, I need a workflow to trigger when any fields change EXCEPT the one w/ the custom ID#.
Any ideas? Thank you.
No one has been able to answer this but I figured it out myself.
I'm including the answer here in case anyone else ever comes across this and finds it helpful:
Create a new field that you will hide from the your SP list and from NewForm.aspx, EditForm.aspx, and DispForm.aspx.
Using jQuery, populate that hidden field as such: $(":input[Title='fieldName']").val("1");
The using an SPD workflow, check to see if that field = 1. If so, run the workflow. AND at the end of that workflow set the field to 0 - that's important.

Delphi memo box won't capture Return key

I have an application with two forms, both are dialogs and they both have memo boxes in them and they both have an OK button on them, however one dialog behaves differently from the other - if I am in the memo area and i type something and then press enter, the form closes but in the other form it goes to the next line in the memo (this is how I want it to behave).
I don't know how to fix the other form so that pressing enter inside the memo does not close it but makes it go to the next line. I even copied the memo component from the 'good' to the 'bad' form and it still does that, also compared the form properties but they are the same! Any idea why this is happening?
Two possibilities:
1) The Memo needs to have the WantReturn in order for the memo itself to process the RETURN key.
2) Check any KeyPress/KeyDown/KeyUp handler on the form that doesn't work to see if they process a RETURN key. If the form has KeyPreview=TRUE then the form's keyboard handler will be executed BEFORE the memo's and if the form's keyhandler processes RETURN then the memo will never see it.

Resources