TDBAdvGrid does not append a record when down-arrow at last record - delphi-2007

I am using TDBAdvGrid to display a database. With other DB Grids, when one attempts to go past the EOF with the down-arrow, a new empty record is automatically appended. This is not happening with TDBAdvGrid. Is there some trick to getting this feature to work?

Set Grid.Navigation.AppendOnArrowDown to TRUE...

Related

Pascal script dataset record delete

I'm experiencing something that I can't figure out. In a Pascal script, I try to delete a record using MyDataset.Dataset.Delete. I'm first opening it with Mydataset.dataset.open, still I get the error "Cannot perform this operation on a closed dataset when evaluating instruction CallProc" on the line where I put the MyDataset.Dataset.Delete instruction. The dataset is consisting of one record that I try to delete. To check if the dataset has a record I did put a showmessagebox with the value of a record field. The messagebox does show data when the script is executed.
Here is my code:
lWorkLeaveBO:=TBusinessObject.Create('WorkLeave');
lWorkLeaveBO.UserSQL:='ObjectID=' + lItemId;
lWorkLeaveBO.Dataset.Open;
showmessage(lWorkLeaveBO.FieldByName('FromDate').AsString);
lWorkLeaveBO.Dataset.Delete;
lWorkLeaveBO.Free; ```

Set Value to a Report Textbox from a Query

I made a query that only shows me a single field and a single record from another query, how can I put that value in a textbox in a report?
The record I want to set is a date that I insert with a MsgBox.
I read that there are ways to just put in the Control Source "=[table]![field]" but I get the Name? error, another way I read but did not understand it is defining a recordset. I can't put the value to the textbox despite trying the ways I've read in other posts.
One simple way is with DLookup() domain aggregate function expression in textbox. If field name has space or punctuation/special characters or is a reserved word, [ ] delimiters will be required. Usually table/query name does not but can't hurt.
=DLookup("[fieldname]","[tableORquery name]")

Microsoft Access 2007 - Auto insert start/end time

I have a table including start time & end time fields. I want to insert the start time, that should be automatically appears when I type something in a row. And I want to insert end time, that also should be automatically appears when i go to the next row.
I have entered as time() in default value from the design view. But I get start time & end time as same. That is not right. What is the correct method to fix this.
Can any one help to me?
Wayne is right as long as you are entering information directly into the table, I do not believe there is anything you can do to record the end time. If you want to use a form this would be possible. Forms are generally better for data entry anyway.
The event you would probably want to use would be "After Update" (ie. After one of the fields change) you could either use the code after the last field (ie. only show end time when the last field is entered or changed) or for every field (this will give the last time any field was updated regardless of order)
The code would look like this (with your actual fields):
Private Sub Field_Name_AfterUpdate()
Me![end time] = Now()
End Sub
You can find the events from the design view click on the field and open the property sheet then go to the event tab and click on the "..." the go to code builder and you would just add the line of code in the middle (make sure the field name matches exactly) (it will automatically add the first and last line)
===========================================
Edit:
Ok so three main things are stopping you right now. I know this can be really difficult when you start, but as soon as you get it to work it will feel amazing.
First - you do NOT want to place the code under starttijd because that field just starts with the default value and never changes. Thus putting code on the Before update or After update will not run. You need to place this in the fields that are updated (ie the fields people fill out with the form) So if they fill out a name for example then you would place the code there
Second - The code is meant to update the END time not the start time ie Me![END]=Now() not Me![starttijd]=Now()
Third - The code you will want to run on After update not before update. Though this is not as important as the above two

Setting AllowBreakAcrossPages property for row in a table

I am working on Windows application with c#.
I have a word document.
I am removing headers & footers in word file programatically.
I am doing this with Microsoft.Office.Interop.Word.
after removing headers and footers, I found some tables got split in pages.
I want to set AllowBreakAcrossPages property to each row of every table.
How to do this in C# code?
Please help me
You need loop all the tables in this word document. note the index start with 1, not 0 if you just want one specific table to set.
For each oTable As Word.Table in appWord.ActiveDocument.Tables
oTable.AllowPageBreaks = False
oTable.Rows.AllowBreakAcrossPages = False 'This line is very important to make it work
next
Check your word document to see whether your target table is embedded in some other, make sure the loop access the target table for the property setting.

How do I get the Proper Item in a Delphi DBLookupComboBox to be Selected

I have a DBLookupComboBox that is wired to a database query. That part is working fine. When I run the program the DBLookupComboBox is populated with the results of the query. I'd like to to see the DBLookupComboBox populated with the first item "Please Select" when the program first runs or when a new item action is initiated. (See below image)
Also, if I'm loading a previously saved database record that had selected Index 2 "Quick Elimination" how would I get the DBLookupComboBox to display that selected entry?
Yes, "Please Select" is index 0 and it is retreived as part of the query.
You could try this (I know you've probably solved it by now, as you asked over 2 years ago), but in case anyone else was interested...
dbluLookup.KeyValue := dbluLookup.ListSource.DataSet.FieldByName(dbluLookup.KeyField).Value;
That simply sets KeyValue to the first record in the ListSource dataset, which should be the row 'Please Select'.
My guess would be that the value of the underlying table field is NULL rather than zero, which tells the DBComboBox that no value has yet been selected and it displays accordingly.
If the value in the table were zero, I thinkg the text in the edit field of the combo would be selected to indicate that, but I may recall this incorrectly.
Anyway, just check for Field1.IsNull (or IsEmpty) and then set it to zero. It does mean that you can no longer distinguish between an "unknown value" (NULL) and "no selected value" (zero), unless you prevent the zero value from making it back into the table...
One way of doing this would be to add 'Please select' to the underlying table from which you are selecting, where the key to this tuple would be 0. Then when you display the combobox and the value of the connected field is 0, 'Please select' would be displayed. Of course, you have to make sure that this value is never selected!
The DBLookupComboBox displays by default the ListField(s) whose KeyField in the ListSource matches the DataField in the DataSource. So, to ensure to display some value for the DataField being NULL, you have to provide a KeyField of NULL in the ListSource. But one could imagine not wanting a NULL value in the underlaying table associated to the ListSource.
One way to circumvent this is to add the NULL value to the dataset behind the ListSource with a UNION SELECT. That should work just fine, since that dataset does not have to be editable.
Now, to assure this special dataset is only available when you are adding a new record to the dataset associated to the DataSource, manage the query for ListSource.DataSet in DataSource.OnStateChange. When DataSource.State = dsInsert, then update ListSource.DataSet.
Modification for Steve Childs answer in TwwDBLookupCombo, InfoPower component
cboFilterTravel1.LookupValue := cboFilterTravel1.LookupTable.FieldByName(cboFilterTravel1.LookupField).Value;
Thanks Steve It's works for me

Resources