updating records in subform

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have my main form frm_bundlelog with a subform frm_bundledocs linked by
the BundleNo and Bundle# fields. I have a button btnupdate on my form that
when I click on it, it would update the AssignedToSub field on my subform
with the value of the AssignedTo field that is on the main form.

I have teh following code:

Private Sub btnupdate_Click()
On Error GoTo Err_btnupdate_Click

Forms!frm_bundlelog!AssignedTo = Forms!frm_bundledocs!AssignedToSub

Exit_btnupdate_Click:
Exit Sub

Err_btnupdate_Click:
MsgBox Err.Description
Resume Exit_btnupdate_Click

End Sub

This is not working. It is not updating the records in the subform and I
get an error stating that "Document Tracking System can't find the form
'frm_bundledocs' referred to in a macro expression or Visual Basic code.

any ideas why?
 
Hi Jean...

I had the same problem with a Main Form and a Sub Form, with the help from
Stefan Hoffmann I came up with the following which works fine for me, I am
using access 97
I have modified the code to use you Names except the Sub Table which your
subform is based, you will have to place the name of you Sub Table in the
line Starting SQL = "UPDATE Tbl_Your_Sub.....

Hope this works, if so pass the thanks onto Stefan Hoffmann

Private Sub btnupdate_Click()
Dim db As DAO.Database
On Error GoTo Err_btnupdate_Click

Dim SQL As String
Set db = CurrentDb()

SQL = "UPDATE Tbl_Your_Sub " & "SET AssignedToSub = '" & Me![ AssignedTo]
& "' " & "WHERE Bundle# = " & Me![ BundleNo]
db.Execute SQL
Me.Refresh
Exit Sub

LocalError:
MsgBox Err.Description
End Sub
 
Back
Top