Sub form add record question

R

Rpettis31

I have a notes subform that lists all the notes that are associated with the
main form. I have a text box (txtAddNotes) that I would like to use to add
notes into the subform.

There is a date field and a notes fields in the sub form and I would like to
set the command button to add the current date and the notes from the text
box.

Private Sub cmdAdNotes_Click()
On Error GoTo Err_cmdAdNotes_Click

Me.subfrmStatusNotes.SetFocus

DoCmd.GoToRecord , , acNewRec

!txtNotes = Me.txtAddNote
!DateCode = Date

Exit_cmdAdNotes_Click:
Exit Sub

Err_cmdAdNotes_Click:
MsgBox Err.Description
Resume Exit_cmdAdNotes_Click

End Sub

I get an unqualified error on the controls on the subform.
 
M

Marshall Barton

Rpettis31 said:
I have a notes subform that lists all the notes that are associated with the
main form. I have a text box (txtAddNotes) that I would like to use to add
notes into the subform.

There is a date field and a notes fields in the sub form and I would like to
set the command button to add the current date and the notes from the text
box.

Private Sub cmdAdNotes_Click()
On Error GoTo Err_cmdAdNotes_Click

Me.subfrmStatusNotes.SetFocus

DoCmd.GoToRecord , , acNewRec

!txtNotes = Me.txtAddNote
!DateCode = Date

Exit_cmdAdNotes_Click:
Exit Sub

Err_cmdAdNotes_Click:
MsgBox Err.Description
Resume Exit_cmdAdNotes_Click

End Sub

I get an unqualified error on the controls on the subform.


DoCmd.GoToRecord won't work that way. Try using:

With Me.subfrmStatusNotes.Form.RecordsetClone
.AddNew
!txtNotes = Me.txtAddNote
!DateCode = Date
,Uodate
End With
 
R

Rpettis31

I figured out the problem... I should have listed it !notes
and then there was a typo with update.

Thanks
Robert
 
M

Marshall Barton

Rpettis31 said:
I figured out the problem... I should have listed it !notes
and then there was a typo with update.


Nice going. I can stare at that kind of thing forever
without seeing it. One reason why I try real hard to name
bound controls with the control type prefix and never prefix
table fields. Even if I can't see it, habit almost always
prevents me from typing it so I don't have to look very
often ;-)
 

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