What's wrong with this Sub?

G

Guest

Private Sub btnCommentSubmit_Click()
On Error GoTo Err_btnCommentSubmit_Click

Me.CommentDate = Now
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Exit_btnCommentSubmit_Click:
Exit Sub

Err_btnCommentSubmit_Click:
MsgBox Err.Description
Resume Exit_btnCommentSubmit_Click

End Sub






I get "The DoMenuItem Action was Canceled" Error

??

Thank you!
 
G

Guest

Try a different method of saving the record, by setting the dirty property to
false:


Private Sub btnCommentSubmit_Click()
On Error GoTo Err_btnCommentSubmit_Click

Me.CommentDate = Now
Me.Dirty = False

Exit_btnCommentSubmit_Click:
Exit Sub

Err_btnCommentSubmit_Click:
MsgBox Err.Description
Resume Exit_btnCommentSubmit_Click

End Sub


Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
 
G

Guest

Hi

Thanks for answering! I replaced my sub, opened my form, entered a comment
in the comment text box, and hit the submit button. The date went into the
CommentDate field ok. but then the form doesn't close. I'm getting

"The setting you entered isn't valid for this property" error

What can I do?

Thanks!
 
G

Guest

Yes, the field type is a date/time General Date (Date and time) already. When
I click submit, the date goes in the box and the error message comes up. I
click OK to the message, and then have to cancel out of my form. but when I
go into my table, the comment and date are there just fine.

It Is there anything else it could be?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top