recordset is not updatable problem

michee

Registered User.
Local time
Today, 12:05
Joined
Sep 11, 2014
Messages
16
I have two forms, both allow for the user to filter the records with two unbound fields. The first is a search form - a multi form set up where they can search through a list of clients and then click a button to pull up the maintenance form - a much more detailed tabulated form which has one page per client and several subforms.

So from the search form I press the button and it calls up the maintenance form and set the filtering values in the to the record from the search form. All of this works great. Somehow though it is making the maintenance form search criteria section "not updatable". anyplace I click up there I get "recordset is not updateable".

I tried adding debugs to see if it was "dirty" or something and interestingly at a point in the code I get runtime errors when I reference the forms properties. Please help. This is the code under the button.

DoCmd.Save
MsgBox "Opening " & Forms!f_client_records_search!CLCL_Display_Name & " For Maintenance"
MsgBox Me.Dirty & " " & Me.Form.Name & "starting value"
' DoCmd.Close
DoCmd.OpenForm "f_maintain_client_record"
DoCmd.GoToControl ("SelectClientMaint")
Forms!f_maintain_client_record!SelectClientMaint.Value = Forms!f_client_records_search!CLCL_Display_Name
Me.Dirty = False
DoCmd.Close acForm, "f_client_records_search"
Forms!f_maintain_client_record.FilterImage_Click
' the following msgbox throws the error "invalid procedure call or argument"
MsgBox Me.Dirty & " " & Me.Form.Name & " end state"
 
Well, two lines up you closed a form. What form did you close? This code will cause the same problem . . .
Code:
DoCmd.Close acForm, Me.Name  [COLOR="Green"]'closes Me[/COLOR]
MsgBox Me.Controls.Count     [COLOR="Green"]'this will cause an error, because Me is now closed[/COLOR]
. . . because we close the form, and then we try to access its Controls collection.
 
I closed the search form but opened the maintenance form

Overall User Story: The user to searches for a client on the search form using the search filters in the form header. They find the client they want by scrolling through the continuous form client list on the search form. They click the "maintenance" button on search form next to the client they want, the maintenance form opens up to the client selected. The search form should then be closed.

I assumed since I opened the maintenance form that focus would move to that form and it would then be the "me" referenced... but clearly not. Do I have to move focus to it to fix that??

In the meantime, I have changed the button module to apply a filter instead of populating the maintenance form's search fields and clicking the button to apply the filtering logic already designed in that form. I was trying to avoid that so that I wouldn't have the code in both places. The new way works (good) but I'm not sure if there was a way to make the old way work? or maybe the new way is better anyway. I'd like to better understand what is setting the recordset as not updatable with the old way, as all I am doing is assigning a value to an unbound field just as happens when I type a value in manually (which doesn't cause a problem).

'NEW CODE BELOW WORKS
Dim param As String
Dim strWhere As String

DoCmd.Save

' save the client name selected in param and let the user know we are opening it for maintenance

param = Forms!f_client_records_search!CLCL_Display_Name
MsgBox "Opening " & Forms!f_client_records_search!CLCL_Display_Name & " For Maintenance"

' close the search form
DoCmd.Close

' build the where clause filter with the client selected and open the maintenance form
strWhere = "([CLCL_Display_Name] Like ""*" & param & "*"") "
DoCmd.OpenForm "f_maintain_client_record", , , strWhere

' ORIGINAL METHOD THAT DOES NOT WORK , was set up after the maintenance form was opened
' go to the filter control on the maintenance form
' DoCmd.GoToControl ("SelectClientMaint")
' populate it with the client selected from the search form
' Forms!f_maintain_client_record!SelectClientMaint.Value = param
' click on the filtering button on the maintenance form
' Forms!f_maintain_client_record.FilterImage_Click
' The maintenance form is giving me a "recordset not updatable error, debug to see if it is dirty?
' MsgBox Me.Dirty & " " & Me.Form.Name & " end state"
 
if anyone is still watching this - I could use an assist. Most of the time my new way of filtering seems to work great. However I keep running into the recordset is not updateable problem. I'm sure someplace I'm setting some value that is triggering it but I can't track it down. Is there a way to debug or set up a watch or something so that I can see where the recordset is getting changed to this status? help
 
So you have a form which has a recordsource that is not updateable. Can you post that records source? Also, what causes it to become not updateable? Is it when you open the form with a filter applied?
 
The form that is currently exhibiting bad behavior is a maintenance form. The main form has a query with multiple tables behind it, driven by CLCL but including the ATTY table for ATTY and an errors query. The main form is not supposed to be updated. I could change all of that to dlookups instead of a multi table query if that is what I need to do. There is more of course. There are two tabs, each of which has two subforms that have "children" tables behind them. The CLCL table is not meant to be updated by the user at this time, just displays client info. The subforms are for data entry of info related to CLCL including: related parties (each client can have one to many related parties - CLRP), notes (each client can have zero to many notes CLNT), doc types (each client can have zero to many matters/docs associated CLDT).

The bad behavior shows up with filtering. Doesn't seem to have anything to do with adding or updating actual data. my filter fields are unbound. I get in, select an atty to filter on, tab and everything works. then I go back and add client info and it works and I change filters back and forth. Then another time it locks out. I haven't nailed down the sequence of events that is triggering it and was hoping to put a watch window or something that I could see when it is triggering. It is possible some subform event is fired - I don't even know WHICH recordset is getting dirty and causing the lock because I assume it could be the subform?? :banghead:
 
Well, something is not updateable, right? What? It is a form, right? So it has a recordsource. What is that recordsource? Also, when it becomes not updateable, what is the filter that is applied? These are facts that you can know.

A form has a filter property. Put an unbound textbox on your form, and set it's controlsource to . . .
Code:
=[Filter]
. . . and it will display the filter text currently applied to the form.

What I am curious about is at the time your form becomes not editable, what is the exact recordsource of the form, and what is the filter.
 
So I've done some additional testing and narrowed the problem down to the unbound control that is used to apply the client filter.

I can change the atty filter back and forth without a problem, but as soon as I filter by client the recordset becomes not updatable. the filter is applied properly but after that the recordset is not updateable. Bottom line is that I don't want to update the recordset and can't figure out what I'm doing that makes access thinks I'm trying to (both filter fields are unbound btw - one is a combo box and the problematic one is just a regular text box).

The event code on the problematic filter box is as follows:

Private Sub SelectClientMaint_LostFocus()
Dim strWhere As String
Dim lngLen As Long 'Length of the criteria string to append to.

If Not IsNull(Me.SelectAttyMaint) Then
strWhere = strWhere & "([ATTY_CK] = " & Me.SelectAttyMaint & ") AND "
End If
If Not IsNull(Me.SelectClientMaint) Then
strWhere = strWhere & "([CLCL_Display_Name] Like ""*" & Me.SelectClientMaint & "*"") AND "
End If

lngLen = Len(strWhere) - 5

If lngLen > 0 Then 'remove the " AND " at the end.
strWhere = Left$(strWhere, lngLen)
'For debugging, remove the leading quote on the next line. Prints to Immediate Window (Ctrl+G).
'Debug.Print strWhere
'Finally, apply the string as the form's Filter.
Me.Filter = strWhere
Me.FilterOn = True
End If

End Sub


the query under the main form is below - note that there is no desire to update the recordset in the form and in fact the fields (other than the filter fields) are all set to not updateable. I do have the form set as edits allowed - I'm not sure why I changed that back from no anymore.

The table relationships are as follows: MSCO has an optional 1:1 relationship to CLCL. The ERRORs thing is a query that is based on an Import_contacts table with no joins - it is simply a way I have centralized my error definition. I put it below in case you would want to see that.

SELECT T_CLCL_Client.CLCL_ExpDate, T_CLCL_Client.ATTY_CK, T_CLCL_Client.CLCL_CK, T_MSCO_Contacts.MSCO_Contact_Type, T_MSCO_Contacts.MSCO_Mail_To_Name, T_MSCO_Contacts.MSCO_Address, T_MSCO_Contacts.MSCO_Address2, T_MSCO_Contacts.MSCO_City, T_MSCO_Contacts.MSCO_State, T_MSCO_Contacts.MSCO_Zip, T_MSCO_Contacts.MSCO_Email_Address, T_MSCO_Contacts.MSCO_Contact_Name, T_CLCL_Client.MSCO_CK, T_CLCL_Client.CLCL_Display_Name, T_CLCL_Client.CLCL_Customer_ID, T_CLCL_Client.CLST_CK, T_CLCL_Client.CMDB_Status, T_CLCL_Client.CLCL_Market_Segment, T_CLCL_Client.CLCL_Referred_By, T_CLCL_Client.CLCL_Anniversary, T_CLCL_Client.CLCL_Input_Errors, T_CLCL_Client.CLCL_CreatedDate, T_CLCL_Client.CLCL_LastUpdatedDate, T_CLCL_Client.CLCL_LastUpdatedDateTime, T_CLCL_Client.CLCL_UpdatedBy, T_CLCL_Client.CLCL_Client_Type, T_CLCL_Client.CLCL_UpdatedRsn, IIf([DisplayNameReqd] Is Not Null,[DisplayNameReqd] & Chr(13) & Chr(10)) & IIf([NicknameReqd] Is Not Null,[nicknamereqd] & Chr(13) & Chr(10)) & IIf([TypeInvalid] Is Not Null,[TypeInvalid] & Chr(13) & Chr(10)) & [professioninvalid] AS Errors
FROM (T_CLCL_Client LEFT JOIN T_MSCO_Contacts ON T_CLCL_Client.MSCO_CK = T_MSCO_Contacts.MSCO_CK) LEFT JOIN [ERROR - CORRECT PRIOR TO IMPORT] ON T_CLCL_Client.CLCL_Customer_ID = [ERROR - CORRECT PRIOR TO IMPORT].[Customer ID]
WHERE (((T_CLCL_Client.CLCL_ExpDate) Is Null));

---- errors query ---
SELECT IMPORT_Contacts.office, IMPORT_Contacts.nickname, IMPORT_Contacts.[Display name], IMPORT_Contacts.Profession, IMPORT_Contacts.[Customer ID], IIf([Display name] Is Null," - Outlook Display Name is required","") AS DisplayNameReqd, IIf([nickname] Is Null," - Nickname is required. Populate Outlook with Formal Mailing Label Name","") AS NicknameReqd, IIf([Office] Is Null,"-Outlook Office is Required. Valid values are: Prospect, Client, Estate, Vendor, Referral, Aide, Attorney, or Inactive",IIf([Office] In ("Prospect","Client","Estate","Vendor","Referral","Aide","Attorney","Inactive"),"","- Outlook OFFICE is set to '" & [Office] & "' which is invalid. Valid values are: Prospect, Client, Estate, Vendor, Referral, Aide, Attorney, or Inactive")) AS TypeInvalid, IIf([profession] Is Null,"-Outlook Profession is Required. Valid values are: Individual, Nonprofit, Business, Estate, All, NA",IIf([profession] In ("Individual","Nonprofit","Business","Estate","ALL","NA"),"","- Outlook PROFESSION is '" & [profession] & "' which is invalid. Valid values are: Individual, Nonprofit, Business, Estate, All, NA")) AS ProfessionInvalid
FROM IMPORT_Contacts
WHERE (((IIf([Office] Is Null,"-Outlook Office is Required. Valid values are: Prospect, Client, Estate, Vendor, Referral, Aide, Attorney, or Inactive",IIf([Office] In ("Prospect","Client","Estate","Vendor","Referral","Aide","Attorney","Inactive"),"","- Outlook OFFICE is set to '" & [Office] & "' which is invalid. Valid values are: Prospect, Client, Estate, Vendor, Referral, Aide, Attorney, or Inactive")))<>"")) OR (((IIf([Display name] Is Null," - Outlook Display Name is required",""))<>"")) OR (((IIf([nickname] Is Null," - Nickname is required. Populate Outlook with Formal Mailing Label Name",""))<>"")) OR (((IIf([profession] Is Null,"-Outlook Profession is Required. Valid values are: Individual, Nonprofit, Business, Estate, All, NA",IIf([profession] In ("Individual","Nonprofit","Business","Estate","ALL","NA"),"","- Outlook PROFESSION is '" & [profession] & "' which is invalid. Valid values are: Individual, Nonprofit, Business, Estate, All, NA")))<>""));
 
Well, something is not updateable, right? What? It is a form, right? So it has a recordsource. What is that recordsource? Also, when it becomes not updateable, what is the filter that is applied? These are facts that you can know.

A form has a filter property. Put an unbound textbox on your form, and set it's controlsource to . . .
Code:
=[Filter]
. . . and it will display the filter text currently applied to the form.

What I am curious about is at the time your form becomes not editable, what is the exact recordsource of the form, and what is the filter.

The exact recordsource is Q_Client_Names (see query in last response) and the exact filter is ([ATTY_CK] = 2) AND ([CLCL_Display_Name] Like "*e*")
 
I have tried removing "errors" from the underlying query and I still get to the point where everything is locked. I also tried changing the data to inconsistent updates with no positive results.:banghead:
 
ok - I seem to have resolved the issue - I have a cascading combo box in a continuous subform. I was setting a value on current record there which was messing up the status of the main form. I'm not certain why that only happened with the client filter nor am I certain it will really fix the problem long term. I have removed the statement but in the process broken the (barely) working subform so I will have to try to work on that now. :(
 

Users who are viewing this thread

Back
Top Bottom