I.T. Discussion Community!
-Collapse +Expand
Delphi
Search Delphi Group:

Advanced
-Collapse +Expand Delphi To/From
To/FromCODEGuides
-Collapse +Expand Delphi Store
PRESTWOODSTORE

Prestwood eMagazine

October Edition
Subscribe now! It's Free!
Enter your email:

   ► MB LobbyPascal and Delphi Coding BoardDelphi Single User Apps Topic   Print This     

DB navigator

DB navigator in Delphi Single User Apps topic (part of our Pascal and Delphi Coding group).

Quick Search: navigator   DB navigator  
rt
Castel, -- UK
Ideally I would like a bit of code that I could activate when say leaving a DBEditBox that would emulate exactly what the post button does on the DB navigator bar without the DB nav bar getting involved at all.

I have tried using 'post' in various guises without success due I suspect to datamodule peakiness!
rt

Thats enough of that. Ed.

 Posted 17 years ago (Thread Starter)
Comment Quote
About rt -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.
About rt

I do like my jazz and blues!


Post ID #7208, 8 replies
Thread Started 8/5/2002 3:32:00 PM
View Counter=2581
Last Reply Posted 8/13/2002 1:50:00 PM)
Location=Castel, -- UK 
Joined=19 years ago   MB Posts=687   KB Comments=1  
rt
Castel, -- UK
I take your point, but it seems to me that the datamodule aspect is knackering the straight 'post' type of operation and so it is only the DB navigator bar that seems to get round the posting problem without exceptions for all and sundry appearing.
Do you fancy (hhhhmmm?) setting out an example of what you suggest and I'll give it a try?
This will of course help increase your postings to the 100 mark ...
rt

Thats enough of that. Ed.

 Posted 17 years ago (Thread Starter)
Comment Quote
About rt -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.
About rt

I do like my jazz and blues!


Post ID #7216 (Level 1.1)  Reply to 7208
Thread Started 8/7/2002 2:23:00 AM
View Counter=2
Location=Castel, -- UK 
Joined=19 years ago   MB Posts=687   KB Comments=1  
rt
Castel, -- UK
Thanks a lot for the effort, I'll have a look at it tomorrow.

Well tomorrow is here, on a quick look it seems to make sense, but just so as I get the full flavour where were you intending to stick the ShowRecord and ClearRecord procedures?

And, with only 7 postings to go now, the accepted tradition is that then you buy us all a drink..
rt

Thats enough of that. Ed.

 Posted 17 years ago (Thread Starter)
Comment Quote
About rt -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.
About rt

I do like my jazz and blues!


Post ID #7222 (Level 1.2)  Reply to 7208
Reply Posted 8/7/2002 3:16:00 PM
Location=Castel, -- UK 
Joined=19 years ago   MB Posts=687   KB Comments=1  
rt
Castel, -- UK
Sorry for the delay but my time has been diverted to an instant tranmission rebuild on the faithful tatty olde horseless Porsche carriage.

But back to Delphi and it will probably come as no surprise to you that I cannot get these 'ere editboxes you suggest to do anything, useful or otherwise.

Maybe I'm not yet back into full Delphi mode so what could I be missing?
rt

Thats enough of that. Ed.

 Posted 17 years ago (Thread Starter)
Comment Quote
About rt -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.
About rt

I do like my jazz and blues!


Post ID #7255 (Level 1.3)  Reply to 7208
Reply Posted 8/12/2002 8:16:00 AM
Location=Castel, -- UK 
Joined=19 years ago   MB Posts=687   KB Comments=1  
Most Recent Post
rt
Castel, -- UK
Thanks, that makes sense and works - it's this bit which seems to make the difference between the two examples "Now, in the DBGrids OnClick event, add the following code."

But in my case all this seems to founder is when a DataModule is involved, so can I now complicate matters by asking what the correct syntax would (should?) be if -Table1.FieldByName'MyField').AsString - were to be replaced by a reference to MyField on Table1 accessed through DataModule1 and using DataSource1

rt

Thats enough of that. Ed.

 Posted 17 years ago (Thread Starter)
Comment Quote
About rt -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.
About rt

I do like my jazz and blues!


Post ID #7272 (Level 1.4)  Reply to 7208
Reply Posted 8/13/2002 1:50:00 PM
Location=Castel, -- UK 
Joined=19 years ago   MB Posts=687   KB Comments=1  
Angel
 (Inactive)
England
Personally I shy away from using the DBEdit boxes and just use standard edits. I then write a show procedure and a clear procedure which will either enter a records data into the corresponding fields, or clear them. I then perform whatever search I am doing to find the required record (be it a search or just a simple next statement), find the record and then call the show procedure. Whenever a user wishes to save a record they then just click a save button which will place the record into edit mode, amend the record (or create a new one if required) and then finally post the changes.

Using DBEdits, when you change the data, the table is put into Edit mode automatically so as you say above, a simple post statement should suffice.
 Posted 17 years ago
Comment Quote
About Angel -Collapse +Expand
Visit Profile
Inactive member.
Member does not subscribe to this thread.
Email Not Verified!
Once email is verified, we will review and approve the account.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #7209 (Level 1.5)  Reply to 7208
Reply Posted 8/6/2002 1:29:00 AM
Location=England  
Joined=18 years ago   MB Posts=199  
Angel
 (Inactive)
England
Oh yee of 300 some postings already!!!

Im up for the challenge, if you can follow this. This is just a form with a TTable, Datasource and the related edit boxes for each field in the table.

My show procedures are something like this.

procedure TForm1.ShowRecord(Sender: TObject);
begin
Edit1.Text := Table1.FieldByName('FIELD1').AsString;
Edit2.Text := Table1.FieldByName('FIELD2').AsString;
Edit3.Text := Table1.FieldByName('FIELD3').AsString;

{ and so on }

end;

whilst a clear procedure is like this.

procedure TForm1.ClearRecord(Sender: TObject);
begin
Edit1.Text := '';
Edit2.Text := '';

{ and so on, alternatively you could use Edit1.Clear }

end;

Now, to search for a record, use the locate feature (or if skipping through using dbnavigator style controls, use Table1.Next and Table1.Prior) like this.

if Table1.Locate('FIELD1', Edit1.Text, []) then
ShowRecord(Sender) else
ClearRecord(Sender);

Doing things this way means you can control exactly when things are posted and edited to the table as the data the user is entering is not live on the table, only entered into an edit box. This makes cancelling a page of input a doddle also.

Hope that makes sense to you.
 Posted 17 years ago
Comment Quote
About Angel -Collapse +Expand
Visit Profile
Inactive member.
Member does not subscribe to this thread.
Email Not Verified!
Once email is verified, we will review and approve the account.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #7218 (Level 1.6)  Reply to 7208
Reply Posted 8/7/2002 2:56:00 AM
Location=England  
Joined=18 years ago   MB Posts=199  
Angel
 (Inactive)
England
You can just put the show and clear record procedures on the same form. Create a procedure entry in the list at the top of your forms code with all the other procedure declarations, just above the public and private sections

procedure ShowRecord(Sender: TObject);

and then anywhere on the form, add the actual procedure code as you would with any other components event handlers.

procedure TForm1.ShowRecord(Sender: TObject);
begin

{Code}

end;
 Posted 17 years ago
Comment Quote
About Angel -Collapse +Expand
Visit Profile
Inactive member.
Member does not subscribe to this thread.
Email Not Verified!
Once email is verified, we will review and approve the account.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #7225 (Level 1.7)  Reply to 7208
Reply Posted 8/8/2002 1:03:00 AM
Location=England  
Joined=18 years ago   MB Posts=199  
Angel
 (Inactive)
England
Simple example time methinks. Setup a form with a TTable, TDatasource, TButton, DBGrid and some Edit boxes. Your also going to need a nice simple table. Setup the relationships between Table datasource and DBGrid in the usual manner. Now, in the DBGrids OnClick event, add the following code.

Edit1.Text := Table1.FieldByName('MYFIELD1').AsString;
Edit2.Text := Table1.FieldByName('MYFIELD2').AsString;
Edit3.Text := Table1.FieldByName('MYFIELD3').AsString;
Edit4.Text := Table1.FieldByName('MYFIELD4').AsString;

Now when you click on the grid and change the selected record, the edit boxes should display the data from the fields you have selected (MYFIELD1 etc). This is uesful because then you have complete control over what the user can and cant edit because the data is not live as it is with DBEdits. This is also more useful on a form where you want to use the edit fields but not a grid.

Writing to the table is simple. You can use the tables record number but personally I always use an identifying field (i.e. an incremental number starting at 1 for each record). This just makes the table a little more stable in my opinion. So to write you would click the button which contains the following code.

Table1.Locate('MYFIELD1', Edit1.Text, []);
Table1.Edit;
Table1.FieldByName('MYFIELD2').AsString := Edit2.Text;
Table1.FieldByName('MYFIELD3').AsString := Edit3.Text;
Table1.FieldByName('MYFIELD4').AsString := Edit4.Text;
Table1.Post;
MessageDlg('Record Saved', mtInformation, [mbok], 0);

Well I prefer to do things this way anyway. The show and clear procedures detailed in the above posts are useful when you need to show data across several forms because you can call the same procedure instead of rewriting it time and again.
 Posted 17 years ago
Comment Quote
About Angel -Collapse +Expand
Visit Profile
Inactive member.
Member does not subscribe to this thread.
Email Not Verified!
Once email is verified, we will review and approve the account.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #7263 (Level 1.8)  Reply to 7208
Reply Posted 8/13/2002 3:18:00 AM
Location=England  
Joined=18 years ago   MB Posts=199  

Revive Thread!

Add a comment to revive this old thread and make this archived thread more useful.

Write a Comment...
Full Editor
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1186A1
Enter key:
Icon: A Post    Thread    Idea    Important!    Cool    Sad    No    Yes    Includes a Link...   
Thread #7208 Counter
2581
Since 4/2/2008

Follow PrestwoodBoards on: 


©1995-2019 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech