MS Access 2007: unable to change fields after "code opening" a form
I'm fighting with creation of several forms in MS Access 2007. I accomplished the following: I have patients form, where I can create / edit patient records. When save button is pressed, I'm opening another form, that has a task of entering information that belong to 2 tables. Tables on that form are in 1-1 relationship, and both use foreign key (patiendID from patients table).
I managed to make everything work fine - when I update / save new patient, I have a new form opened with a bunch of lab results to be entered. Some of the results belong to one table, and other to another table. patientID field, that is also visible on that 2nd form is set as it should be. However, when I try to enter ANY value in ANY field on that form - I get following warning on the status bar: "This Recordset is not updateable". I think that this has smt to do with the fact that I actually opened 2 tables on a single form, but I might be very wrong.
Here is the code I use to open 2nd form:
Private Sub save_Click()
Dim m_query As String
m_query = "INSERT INTO labresults (patientID) VALUES (" & Me.ID & ")"
If Me.Dirty = True Then
Me.Dirty = False
End If
If DCount("patientID", "labresults", "patientID = " & Me.ID) = 0 Then
CurrentDb.Execute m_query, dbFailOnError
End If
m_query = "INSERT INTO par14MO (patientID) VALUES (" & Me.ID & ")"
If DCount("patientID", "par14MO", "patientID = " & Me.ID) = 0 Then
CurrentDb.Execute m_query, dbFailOnError
End If
If CurrentProject.AllForms("labresults").IsLoaded = True Then
Forms![labresults]![patientID] = Me.ID
Forms![par14MO]![p开发者_Python百科atientID] = Me.ID
Else
DoCmd.OpenForm "labresults", acNormal, , "idPAcijenta = " & Me.ID, acFormEdit, acWindowNormal, Me.ID
End If
End Sub
Any ideas what's going on???
Thx a bunch! I'm still googling and trying... I'll post my findings if I manage to sort things out!
Turns out that this really cannot be done :). Closing this one, and assuming this is an answer.
Edit: It was suggested to me that my last statement is not true. However, I solved things "manually", and everything is ok now. I'll go on and accept this answer in order to keep my response at a good level.
精彩评论