Problem using the UPDATE command in VBA

Reply

Join Date: Jul 2004
Posts: 6
Reputation: Taffy-Taff is an unknown quantity at this point 
Solved Threads: 0
Taffy-Taff Taffy-Taff is offline Offline
Newbie Poster

Problem using the UPDATE command in VBA

 
0
  #1
Dec 25th, 2004
Hi :
I am having a problem and I can't seem to figure out what is wrong.
This is it:

I have a table with a memo field called MonthComment. It also has a field called Historic_comments
I have a form containing 2 text boxes. One text box called Historic_comments and the other called New_comments. The Historic_comments textbox contain any comment that was on a record at the time the form is loaded, and this information comes from the MonthComment field in the Table.
Persons can now type comments in the New_comments textbox. The system will check if a comment existed before, and if it does, it will combine the old comment with the new comment and put this combined data in the Historic_comments textbox. It will then take it from the data from the Historic_comment textbox and store it in the MonthComment field in the table.
I use the Dcount function to check if there is a comment for the record. Each record in this table must have a comment, so if a comment does not exist, it means that the record does not exist in this table. I store the result in a variable called Comment_exist.
I use the following command to do the saving:



If comment_exist > 0 Then 'comment exist, so update the comment
DoCmd.RunSQL "Update tblComments set MonthComment = forms!wk12rp!historic_comments where customer_code = forms![Get list of customers]!cust_num"

Else 'comment doesnt exist: Add the customer code and the comment
DoCmd.RunSQL "Insert into tblComments (customer_code, monthComment) values (cust_num,new_comments)"


End If

I am having two problems with this: The first is with the Insert Into command. If the comment for the record is about 100 or less characters, this works fine. However, if the comment is longer than that, it gives me a "Invalid argument" error.
The other problem is with the Update command. If the comment is short, it works fine. If you input a series of short comments (eg. Called and left message) it will keep updating the MonthComment field until the total length of the field is to be about 100 characters. My taking on this is that, since the MonthComment field is a Memo field, it should accept any length string. Am I wrong? What am I doing wrong? How can I get around this?

I really need your help in the shortest possible time.


Thanks
Taffy
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 200
Reputation: mnemtsas is an unknown quantity at this point 
Solved Threads: 1
mnemtsas's Avatar
mnemtsas mnemtsas is offline Offline
Junior Poster

Re: Problem using the UPDATE command in VBA

 
0
  #2
Jan 3rd, 2005
Is the comment field in the database a string limited to 100 characters? If it is that could be your problem. Try making it a longer string or a memo instead.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC