Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add and update records in table?

Status
Not open for further replies.

lespaul

Programmer
Feb 4, 2002
7,083
US
I have a table in the database that I need to allow users to directly update (I know that's a scary thought, but it's a pretty simple table that stores dates and specific events). So my table, JMPTERMS has the following fields:
AppearanceDate, MailDate, Request, NRPrint, CurrentAppearance. The users need to be able to add AppearanceDate and update MailDate. Can I use a DBGrid? For AppearanceDate the user only needs to know the last entered date, but MailDate needs to show all AppearanceDate records that don't have a mail date. All the other fields are program oriented and the users don't need to see them at all. Any suggestions? Leslie
landrews@metrocourt.state.nm.us

SELECT * FROM USERS WHERE CLUE > 0
No Rows Returned
 
Hi Leslie -

Is the problem a matter of filtering the data ? If you are using the generic paradox/BDE solution - base the DBGrid on a table - then set the tables filter property. Here is an example :

Var
T : String;
FromDate : TDateTIme;
FilterStr : string;
begin

FromDate := StrToDate('10/01/1989');
T := DateToStr(FromDate);
FilterStr := 'DATE_OPEN > ' + QuotedStr(T);
Table1.Filter := FilterStr;
Table1.Filtered := true;


Here table1 (which you can use the clients table in DBDEMOS to test) has its results filtered so that values in DATE_OPEN fall later than the FromDate shown.

Hope it helps..

Opp.




 
Thanks Opp! That will help for setting the mail dates (since I only want to show records that don't have a maildate), but I guess my main question is: Can I [bold]add[/bold] records to a table from a DBGrid? If so, how do I implement that? So, I have a main menu selection: Venire Date Maintenance. When this is selected, I want to open a form that has a DBGrid that shows all the records where the MailDate field is blank. The user can then either enter a mail date for an existing record or add a new record. If possible I'd also like for the user to enter the date information (both for updating maildate and entering new veniredate) in the standard format (mm/dd/yyyy) and prior to updating the database convert that to YYYYMMDD (the proper database format). Or do I need to have the user enter the date in the YYYYMMDD format? Thanks!

Leslie


SELECT * FROM USERS WHERE CLUE > 0
No Rows Returned
 
Ok, so I have my dataset attached to the DBGrid. There are two columns: Venire Date and Mail Date. I am only returning records where Mail Date = ''. I can edit records to add the mail date. But I can't figure out how to ADD records. I also can't get the date to be formatted. The database dates are structured YYYYMMDD (which looks fine to me, but you know how those picky users are!! LOL). Can I format the data before displaying in the Grid and then convert to the proper database format before posting the data? Which events would I use? THANKS!!! Leslie
landrews@metrocourt.state.nm.us

SELECT * FROM USERS WHERE CLUE > 0
No Rows Returned
 
Ok, I've added a button that inserts a record, but it's not exactly what I'd like (the user has to press the button each time). At the beginning of each year, we know all the dates for that year. Is there anyway to have the user enter in the list of dates and then loop through the list and enter each line item into the database?

01/06/2002
01/20/2002
02/03/2002
02/17/2002 (etc for whole year)

convert each item in list to YYYYMMDD and insert?

Thanks!

la
Leslie
landrews@metrocourt.state.nm.us

SELECT * FROM USERS WHERE CLUE > 0
No Rows Returned
 
You know the dates, use a dblistbox or dbcombobox, to insert a record, press ins

Regards Steven van Els
SAvanEls@cq-link.sr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top