Form button to populate fields

miked1978

New member
Local time
Yesterday, 19:56
Joined
May 22, 2020
Messages
25
I have a button on my main form that when clicked I want to populate 3 fields on the subform. The weird thing is I have another form that this works perfectly in, I literally copied the code and replaced the form names and the field names.

Anyway I get an error "Access cant find the field 'tbAssigned_WorkOrders_subform' referred to in your expression"

The code that works doesn't have a field on that line, just the form and subform name. I replaced it with my Assigned field just to see but I then get an error saying it cant find the OBJECT 'tbAssigned_WorkOrders_subform'


Code:
Private Sub cmd_AssignOrder_Click()

Set rsc = Forms![tbAssigned_Orders_Form]![tbAssigned_WorkOrders_subform].Form.RecordsetClone                            'Errors out here
rsc.MoveFirst  ' Because you have ran through the recordset once it ensures that you are starting back at the top.

Do While Not rsc.EOF
If rsc!Assigned = False Then

        rsc.Edit
        rsc!Assigned = True
        rsc!Assigned_User52 = fOSUserName
        rsc!Assigned_Date = Date + Time
        rsc.Update
          
    End If
rsc.MoveNext
Loop

End Sub

thoughts?
 
It cannot find the form subcontrol?, not always the same as the subform name?
 
The control that surrounds the subform. Click on the outer edge of the subform.
 
It's the name of the container that the subform is sitting in, embedded in, on the main form.
You have to click arouind a bit on the edges and corners of things (while watching the Property window) to get it
 
Got it. Same name but one had a space and the other has a "_" in the name

Thanks I really appreciate it!!!
 

Users who are viewing this thread

Back
Top Bottom