Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a spreadsheet that pulls some data from an Access database and
populates cells. Some of the cells have a comment that needs to be added. The code I am trying is as follows (rs2 is the DAO recordset): ActiveSheet.Cells(mrow, mcol).Value = rs2![code] If Not IsNull(rs2![Comments]) Then ActiveSheet.Cells(mrow, mcol).ClearComments ActiveSheet.Cells(mrow, mcol).AddComment rs2![Comments] End If When I execute this code, at the AddComment line I get the following error: Run-time error '1004': Application-defined or object-defined error I get this error sometimes when I attempt to add a comment to a field that already has a comment, which is why I added the ClearComments line before it -- but the presence or absence of the ClearComments line doesn't seem to make any difference. I use some code similar to this successfully in another place in my application, but I'm using the text from a textbox instead of a recordset field to set the comment. Does anyone see anything wrong with this code? Or is there something additional I need to do to add the comment? If it makes any difference, the Comments field from my database is a Memo field. I can use a MsgBox to see the Comments field and it looks OK. Thanks for any suggestions, Carl Rapson |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Carl
your code looks o.k. for me. You may try the following: Replace ActiveSheet.Cells(mrow, mcol).AddComment rs2![Comments] with ActiveSheet.Cells(mrow, mcol).AddComment CStr(rs2![Comments]) -- Regards Frank Kabel Frankfurt, Germany Carl Rapson wrote: I have a spreadsheet that pulls some data from an Access database and populates cells. Some of the cells have a comment that needs to be added. The code I am trying is as follows (rs2 is the DAO recordset): ActiveSheet.Cells(mrow, mcol).Value = rs2![code] If Not IsNull(rs2![Comments]) Then ActiveSheet.Cells(mrow, mcol).ClearComments ActiveSheet.Cells(mrow, mcol).AddComment rs2![Comments] End If When I execute this code, at the AddComment line I get the following error: Run-time error '1004': Application-defined or object-defined error I get this error sometimes when I attempt to add a comment to a field that already has a comment, which is why I added the ClearComments line before it -- but the presence or absence of the ClearComments line doesn't seem to make any difference. I use some code similar to this successfully in another place in my application, but I'm using the text from a textbox instead of a recordset field to set the comment. Does anyone see anything wrong with this code? Or is there something additional I need to do to add the comment? If it makes any difference, the Comments field from my database is a Memo field. I can use a MsgBox to see the Comments field and it looks OK. Thanks for any suggestions, Carl Rapson |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Frank,
Thank you very much, that did the trick. I guess there was a problem after all with the database field being a memo field. I learn something every day through these newsgroups. Carl "Frank Kabel" wrote in message ... Hi Carl your code looks o.k. for me. You may try the following: Replace ActiveSheet.Cells(mrow, mcol).AddComment rs2![Comments] with ActiveSheet.Cells(mrow, mcol).AddComment CStr(rs2![Comments]) -- Regards Frank Kabel Frankfurt, Germany Carl Rapson wrote: I have a spreadsheet that pulls some data from an Access database and populates cells. Some of the cells have a comment that needs to be added. The code I am trying is as follows (rs2 is the DAO recordset): ActiveSheet.Cells(mrow, mcol).Value = rs2![code] If Not IsNull(rs2![Comments]) Then ActiveSheet.Cells(mrow, mcol).ClearComments ActiveSheet.Cells(mrow, mcol).AddComment rs2![Comments] End If When I execute this code, at the AddComment line I get the following error: Run-time error '1004': Application-defined or object-defined error I get this error sometimes when I attempt to add a comment to a field that already has a comment, which is why I added the ClearComments line before it -- but the presence or absence of the ClearComments line doesn't seem to make any difference. I use some code similar to this successfully in another place in my application, but I'm using the text from a textbox instead of a recordset field to set the comment. Does anyone see anything wrong with this code? Or is there something additional I need to do to add the comment? If it makes any difference, the Comments field from my database is a Memo field. I can use a MsgBox to see the Comments field and it looks OK. Thanks for any suggestions, Carl Rapson |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Carl
that was just a good guess :-) - so glad it helped -- Regards Frank Kabel Frankfurt, Germany Carl Rapson wrote: Frank, Thank you very much, that did the trick. I guess there was a problem after all with the database field being a memo field. I learn something every day through these newsgroups. Carl "Frank Kabel" wrote in message ... Hi Carl your code looks o.k. for me. You may try the following: Replace ActiveSheet.Cells(mrow, mcol).AddComment rs2![Comments] with ActiveSheet.Cells(mrow, mcol).AddComment CStr(rs2![Comments]) -- Regards Frank Kabel Frankfurt, Germany Carl Rapson wrote: I have a spreadsheet that pulls some data from an Access database and populates cells. Some of the cells have a comment that needs to be added. The code I am trying is as follows (rs2 is the DAO recordset): ActiveSheet.Cells(mrow, mcol).Value = rs2![code] If Not IsNull(rs2![Comments]) Then ActiveSheet.Cells(mrow, mcol).ClearComments ActiveSheet.Cells(mrow, mcol).AddComment rs2![Comments] End If When I execute this code, at the AddComment line I get the following error: Run-time error '1004': Application-defined or object-defined error I get this error sometimes when I attempt to add a comment to a field that already has a comment, which is why I added the ClearComments line before it -- but the presence or absence of the ClearComments line doesn't seem to make any difference. I use some code similar to this successfully in another place in my application, but I'm using the text from a textbox instead of a recordset field to set the comment. Does anyone see anything wrong with this code? Or is there something additional I need to do to add the comment? If it makes any difference, the Comments field from my database is a Memo field. I can use a MsgBox to see the Comments field and it looks OK. Thanks for any suggestions, Carl Rapson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Adding a picture to a comment box | Excel Discussion (Misc queries) | |||
Adding a new comment with a function? | Excel Discussion (Misc queries) | |||
Programmatically adding buttons to a worksheet (Shape Object) | Excel Programming | |||
Excel - adding control programmatically. | Excel Programming | |||
Adding Checkboxes Programmatically | Excel Programming |