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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Memo box to edit database...so frustrated, please help 3

Status
Not open for further replies.

Jonah86

Programmer
Dec 11, 2003
152
US
Ok. I have a form which has some dbedit boxes that are tied to one query, and then a dbgrid tied to another query, now I just added another form that comes up to add comments in the database. This form has only one dbmemo that is tied to the same database as the dbedits on the other form. Strange thing is, I can add a comment as big as I want(up to the size of the field anyway), but then if I want to edit that comment and make it smaller...and then later make it large again...it wont go any bigger than when I shrunk it. I know this sounds confusing, I'm sorry I'm just a little frazzled(it's a word!) right now. The way I'm updating the query from the memo is:

datamodule.query.edit;
datamodule.query.post;

That's the only way I could get it to work, and it does work except in this instance.

Also, on the dbgrid that's tied to a whole other query...I get a similar problem where I can add a record to the db...and it's there...but if I try to make it longer than the data I entered it wont do it. I can make it shorter and change it...but not longer. Never longer than the original data I entered. I don't do anything to update the grid, just change the data and hit the post button on the little controller bar I added.

In the actual database I can do these things...as best I can tell. So I BELIEVE the problem is in the code. I'm just not sure what it might be.

I'm using BDE, and a MySQL database. I'm about to throw this thing out the window.

Thanks:)
 
hi

This is a strange problem. First, have you tried updating the database directly with an UPDATE statement (in SQL Explorer or similar) to see if you get the same problem? If you don't, then it must be in the code, can you post more of it here?

lou

 
See, that's the odd thing. I'm not using much code to do this. The dbgrid has no code, I just edit directly in the grid. But the form that has the memo box only has those edit and post commands to do the updating. I wasn't entirely sure going into doing this how I should do the update from that form, I haven't had any problems entering data...just when I edit. I tried the 'commit changes' command..but that then cleard all the other fields in the record...so I guess that wasn't it. I wish I could be more helpful about giving info, but I just don't have a clue what the problem may be.

Thank you for stoping to read this.
 
Dont use a DBMemo, just use a standard memo. It means doing a little bit more coding but it means more stability too. In my experience I have found the DBEdits,memos etc a little too flimsy to be of any real use.
Code:
Memo1.Lines.Text := MyQuery.FieldByName('MYMEMOFIELD').AsString;

MyQuery.Edit;
MyQuery.FieldByName('MYMEMOFIELD').AsString := Memo1.Text;
MyQuery.Post;
This should sort out your problem

When your feeling down and your resistance is low,
light another cigarette and let yourself go!
 
Ok, I tried that method, that it does the same thing. Let me walk you through the steps it takes to get this error to happen.

I search the db
Select the project I want to view
On the page where I view the project info there is a button that opens the form to edit the comment field
I make the comment shorter
I go back to the main form
I search again
When I'm back on the view form and try to make the comment longer it won't let me make it any longer than it was when I last exited the view form.

Say the field was originally 20 characters, and I go in and shorten it to 10, before I exit the form I can make it long again...but once I exit the form I can never again make it longer than what it was when I exited the form. This also happens in the dbgrid that is tied to a different db, only in the grid it simply wont let me type a word longer than the size it was when I exited the form, the memo will let me type it and then cut it off when I post it.

I'm losing my mind, thank your helping.
 
Here's an interesting one. If I delete the whole contents of the memo, leave the view form, search go back to the view form and try to add the comment field...I can add any length I want up to the field size. So this only happens if I shorten the data but still leave some data in there. What the freak!?
 
Hmm...oddly enough, in the grid, if I make one of the fields long...the rest of the records can have that length for that field. This is if I add a new record and make one of it's fields as long as I can...the rest of the records can have that field be that long...but only that long. Say I add a new item with the rmark field 20 chars long, then I can edit the other item's remark fields to be up to 20 chars long, but if the longest one is only 10...the rest can only be up to 10.

As I said these are different queries accessing different dbs, but based on a matching criteria. This is so odd.
 
I think I know the basics of what is happening to me here. It seems that whenever I execute a query the longest field sets the max length for all the other fields. So if I execute a query that has say 'recordnum' in it somewhere, and the maximum record number is 20 then none of the other record numbers can be more than 2 digits, they can less or equal 2 digits...but not more. I can enter a new record that has a 3 digit record number...but not edit one. So when I execute a query that has only one resulting record...then all the fields for that record are the max length they can be. But it only changes when I reactivate the query, hence all the going back and searching again.

While, I think I know why it's happening I can't figure how to make it stop. Is there any way to get the dumb thing to just use the field lengths set in the database?

If anyone can help you'd be making me want to kill myself SO much less. Thanks.
 
Is this a dynamic query where you're setting the SQL at runtime, or is it a query that's been set in the IDE and you just update parameters at runtime? If it's the latter, you can set up persistent fields which might take care of your problem.

-D
 
It's dynamic. I use the queries to do searches and the like. I just don't get what the problem could be. Why would it not just adhere to the field sizes set up in the database? Is there some setting on the query object that can be changed, or something that might make this happen?

I guess a better question is, has this happened to anyone else? There is another guy in my office writing a program who is beginning to experience this problem...and I just don't know what to do.
 
So, can I assume that no one has any clue as to why this might be happening? Oh well, thanks for all your effort.
 
Well hey, I found the problem. If anybody else has an issue like this, in the ODBC connection there is an option to not optimize collumn length...check that and everything went smoothly. Thanks for any help anyone has given me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top