ok...I've made sure that the properties AllowEdits, AllowAdditions, and AllowDeletions are all set to true on the main and subforms. It was also suggested that the Recordset be a type that allows updating. Following are the two versions of my RequeryForm() method. One deals with the Recordset directly, while the other doesn't. Both work in the sense that they display the proper data, but neither allow me to edit any of the fields in the subforms. Someone please tell me what needs to be included in my code to ensure the subforms are editable!
Alan
Code:
Public Sub RequeryForm()
On Error GoTo ErrHandler
'Obtain the name of the Employee first and display in top label
Me.Label10.Caption = GetName(CLng(Module1.employeeID))
'Create an SQL statement for the frmLANDLINES recordsource property
Module1.landlineSQL = "SELECT LANDLINES.DEVICE_ID, LANDLINES.LANDLINE_CC, LANDLINES.LANDLINE_NUMBER, LANDLINES.LANDLINE_PORT, LANDLINES.LANDLINE_JACK" & _
" FROM LANDLINES, COMMUNICATIONS WHERE COMMUNICATIONS.EMPLOYEE_ID=" & Module1.employeeID & " AND COMMUNICATIONS.DEVICE_ID=LANDLINES.DEVICE_ID AND COMMUNICATIONS.DEVICE_TYPE='Landline';"
Me.frmLANDLINES.Form.RecordSource = Module1.landlineSQL
Me.frmLANDLINES.Requery
'Create an SQL statement for the frmMobile recordsource property
Module1.mobileSQL = "SELECT MOBILE.DEVICE_ID, MOBILE.MOBILE_CC, MOBILE.MOBILE_TYPE, MOBILE.MOBILE_NUMBER" & _
" FROM MOBILE, COMMUNICATIONS WHERE COMMUNICATIONS.EMPLOYEE_ID=" & Module1.employeeID & " AND COMMUNICATIONS.DEVICE_ID=MOBILE.DEVICE_ID AND COMMUNICATIONS.DEVICE_TYPE='Mobile';"
Me.frmMobile.Form.RecordSource = Module1.mobileSQL
Me.frmMobile.Requery
ErrHandler:
If Err.number = 2467 Then
MsgBox Err.number & "One of the subforms or tables (LANDLINES or MOBILE) is already open by you or someone else." & vbCrLf & _
"It needs to be closed before you can view the COMMUNICATIONS form in its entirety.", vbOKOnly
Exit Sub
End If
If Err.number <> 0 Then
MsgBox Err.number & " Description: " & Err.Description, vbExclamation
Exit Sub
End If
End Sub
Code:
Public Sub RequeryForm()
Dim rst As Recordset
'On Error GoTo ErrHandler
'Obtain the name of the Employee first and display in top label
Me.Label10.Caption = GetName(CLng(Module1.employeeID))
'Create an SQL statement for the frmLANDLINES recordsource property
Module1.landlineSQL = "SELECT LANDLINES.DEVICE_ID, LANDLINES.LANDLINE_CC, LANDLINES.LANDLINE_NUMBER, LANDLINES.LANDLINE_PORT, LANDLINES.LANDLINE_JACK" & _
" FROM LANDLINES, COMMUNICATIONS WHERE COMMUNICATIONS.EMPLOYEE_ID=" & Module1.employeeID & " AND COMMUNICATIONS.DEVICE_ID=LANDLINES.DEVICE_ID AND COMMUNICATIONS.DEVICE_TYPE='Landline';"
Set rst = New ADODB.Recordset
rst.Open Module1.landlineSQL, CurrentProject.Connection, adOpenKeyset, adLockOptimistic, adCmdText
Set Me.frmLANDLINES.Form.Recordset = rst
Me.frmLANDLINES.Requery
'Create an SQL statement for the frmMobile recordsource property
Module1.mobileSQL = "SELECT MOBILE.DEVICE_ID, MOBILE.MOBILE_CC, MOBILE.MOBILE_TYPE, MOBILE.MOBILE_NUMBER" & _
" FROM MOBILE, COMMUNICATIONS WHERE COMMUNICATIONS.EMPLOYEE_ID=" & Module1.employeeID & " AND COMMUNICATIONS.DEVICE_ID=MOBILE.DEVICE_ID AND COMMUNICATIONS.DEVICE_TYPE='Mobile';"
Set rst = New ADODB.Recordset
rst.Open Module1.mobileSQL, CurrentProject.Connection, adOpenKeyset, adLockOptimistic, adCmdText
Set Me.frmMobile.Form.Recordset = rst
Me.frmMobile.Requery
ErrHandler:
If Err.number = 2467 Then
MsgBox Err.number & "One of the subforms or tables (LANDLINES or MOBILE) is already open by you or someone else." & vbCrLf & _
"It needs to be closed before you can view the COMMUNICATIONS form in its entirety.", vbOKOnly
Exit Sub
End If
If Err.number <> 0 Then
MsgBox Err.number & " Description: " & Err.Description, vbExclamation
Exit Sub
End If
End Sub