S
SandyR
This problem occurs in the on-click event of an unbound combo box in a
nested subform. When a record is selected from the combo box, I want to
update that record with the crewid from the parent form. When I try to
assign the value, I get the message "you can't assign a value to this
object". How should I be referring to this field to make this work? Here
is the code with the error line indicated:
Private Sub cboEmpno_Click()
Dim Rst As DAO.Recordset
Dim dbs As Database
Dim stsql As String
Dim STWHERE As String
On Error GoTo List2_Click_Error
' Set Rst = Me.RecordsetClone
stsql = "SELECT tbldayemps.empno, tbldayemps.crewno, tbldayemps.logday "
stsql = stsql & "FROM tbldayemps WHERE ((tbldayemps.crewno)=0) "
stsql = stsql & " AND (( tbldayemps.logday )= #" &
[Forms]![dailylog].[Form]![cboTdate] & "# )"
Set dbs = CurrentDb
Set Rst = dbs.OpenRecordset(stsql, dbOpenDynaset)
STWHERE = "empno = " & Me![cboEmpno]
Rst.FindFirst STWHERE
' the following statement should never be true
If Rst.NoMatch Then
MsgBox "no match"
End If
Me!crewno = Me.Parent!cboCrewid <======= error occurs here
Me.Dirty = False
Me.Requery
Me.cboEmpno.Requery
List2_Click_exit:
On Error GoTo 0
Exit Sub
List2_Click_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure
List2_Click of VBA Document Form_members subform"
Resume List2_click_exit
end sub
nested subform. When a record is selected from the combo box, I want to
update that record with the crewid from the parent form. When I try to
assign the value, I get the message "you can't assign a value to this
object". How should I be referring to this field to make this work? Here
is the code with the error line indicated:
Private Sub cboEmpno_Click()
Dim Rst As DAO.Recordset
Dim dbs As Database
Dim stsql As String
Dim STWHERE As String
On Error GoTo List2_Click_Error
' Set Rst = Me.RecordsetClone
stsql = "SELECT tbldayemps.empno, tbldayemps.crewno, tbldayemps.logday "
stsql = stsql & "FROM tbldayemps WHERE ((tbldayemps.crewno)=0) "
stsql = stsql & " AND (( tbldayemps.logday )= #" &
[Forms]![dailylog].[Form]![cboTdate] & "# )"
Set dbs = CurrentDb
Set Rst = dbs.OpenRecordset(stsql, dbOpenDynaset)
STWHERE = "empno = " & Me![cboEmpno]
Rst.FindFirst STWHERE
' the following statement should never be true
If Rst.NoMatch Then
MsgBox "no match"
End If
Me!crewno = Me.Parent!cboCrewid <======= error occurs here
Me.Dirty = False
Me.Requery
Me.cboEmpno.Requery
List2_Click_exit:
On Error GoTo 0
Exit Sub
List2_Click_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure
List2_Click of VBA Document Form_members subform"
Resume List2_click_exit
end sub