João serras-pereira
asked on
write conflict
Hi
On my app I am getting now the warning "write conflict" as per the below message.
This happens when I try to close a form (and I am the single user...) after, on a subform I updated the record on the master form. If if click SAVE RECORD then the data is destroyed. If I click either COPY or DROP then it's OK. I do not want the user to get this annoying message.
How (i) can I do something to avoid the "stupid" message by disabling some automatic change that is nowhere or (ii) just pre-select the DROP and avoid showing the message
Can anyone help?
On my app I am getting now the warning "write conflict" as per the below message.
This happens when I try to close a form (and I am the single user...) after, on a subform I updated the record on the master form. If if click SAVE RECORD then the data is destroyed. If I click either COPY or DROP then it's OK. I do not want the user to get this annoying message.
How (i) can I do something to avoid the "stupid" message by disabling some automatic change that is nowhere or (ii) just pre-select the DROP and avoid showing the message
Can anyone help?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Dale
does
me.parent.txt_SomeField = me.somevalue
need to be bound?
btw - the doctor LOVED the output of your grid Idea...
does
me.parent.txt_SomeField = me.somevalue
need to be bound?
btw - the doctor LOVED the output of your grid Idea...
As the others suggested, you are conflicting with yourself. You have code that is dirtying a form and then perhaps using DAO or a query to update it. We can't really offer a solution without knowing how the problem is caused.
ASKER
Hi Pat, Dale -
Here is what I have (my problem is that the error message just pops up without letting me where it really comes from, except when I press a close button or after close when I change current record in the master table
I have a main form and a subform
Mainform is bound to a table [tblExame] - [tblExame], contains 3 fields that, actually, are the keys for 3 images in [tblImagem]
SubForm Is bound [tblImagem] - actual sets of images to select for one Exam in tblExame]
[tblImagem] is a "sub" table of [tblExame]
This is Ok and forms behave - linked fields are OK
So what I what to do is quite simple:
On the SUBFORM (related to [tblImage] I pick out of the set of images (20 - 30) the 3 images and update the 3 fields in the main table [tblExam]. They are correctly updated (I am using DAO for this)
then I close the form and come to another form that lists all records in [tblExame].
Now, if I try to close this form, or change the "current record" of the list going to another record of [tblExame] I get the message.
The code in the subform is:
And the Select statement is the update, now with dale's suggestion, but without results.
Of course I can send the database, just let me know
Hope this is enough
Here is what I have (my problem is that the error message just pops up without letting me where it really comes from, except when I press a close button or after close when I change current record in the master table
I have a main form and a subform
Mainform is bound to a table [tblExame] - [tblExame], contains 3 fields that, actually, are the keys for 3 images in [tblImagem]
SubForm Is bound [tblImagem] - actual sets of images to select for one Exam in tblExame]
[tblImagem] is a "sub" table of [tblExame]
This is Ok and forms behave - linked fields are OK
So what I what to do is quite simple:
On the SUBFORM (related to [tblImage] I pick out of the set of images (20 - 30) the 3 images and update the 3 fields in the main table [tblExam]. They are correctly updated (I am using DAO for this)
then I close the form and come to another form that lists all records in [tblExame].
Now, if I try to close this form, or change the "current record" of the list going to another record of [tblExame] I get the message.
The code in the subform is:
Private Sub btnAssociarImagem_Click()
Dim LifeLingerDB As DAO.Database
Dim q02_exameSet As DAO.Recordset
Dim q02_exameDef As QueryDef
Dim strSetSQL As String
Dim bUpdate As Boolean
Dim intIdPaciente As Integer
Dim strFilePath, _
strImgPath As String
Dim nIdImagem, _
nIdExame As Integer
'On Error GoTo errorTrap
Call logMe("btnAssociarImagem_Click", "start")
Forms![_intData].frm_idImagem = Nz(Me.frm_idImagem, 0)
nIdImagem = Nz(Me.frm_idImagem, "0")
strImgPath = Nz(DLookup("imgPath", "tblImagem", "idImagem =" & nIdImagem), "")
If strImgPath = "" Then
MsgBox "Erro Interno, Imagem [" & nIdImagem & "] não localizada"
Call logMe("btnAssociarImagem_Click", "Erro Interno, Imagem [" & nIdImagem & "] não localizada")
Exit Sub
End If
nIdExame = Nz(Forms![_intData].frm_idExame, 0)
Set LifeLingerDB = CurrentDb
Set q02_exameDef = LifeLingerDB.QueryDefs("q02_exame")
strSetSQL = "SELECT "
strSetSQL = strSetSQL & "tblExame.IDpaciente, "
strSetSQL = strSetSQL & "tblExame.IDexame, "
strSetSQL = strSetSQL & "tblExame.DataExame, "
strSetSQL = strSetSQL & "tblExame.MotivoExame, "
strSetSQL = strSetSQL & "tblExame.Observacao, "
strSetSQL = strSetSQL & "tblExame.Diagnostico, "
strSetSQL = strSetSQL & "tblExame.Orientacao, "
strSetSQL = strSetSQL & "tblExame.imgIdNormal, "
strSetSQL = strSetSQL & "tblExame.imgIdAcidoAcetico, "
strSetSQL = strSetSQL & "tblExame.imgIdShiller "
strSetSQL = strSetSQL & "FROM tblExame "
strSetSQL = strSetSQL & "WHERE (((tblExame.idexame)= "
strSetSQL = strSetSQL & nIdExame
strSetSQL = strSetSQL & "));"
q02_exameDef.SQL = strSetSQL
Set q02_exameSet = LifeLingerDB.OpenRecordset("tblExame", dbOpenDynaset)
' testar se a imagem já está associada a um tipo no exam
With q02_exameSet
If Nz(!imgIdNormal, 0) = Me.frm_idImagem Or _
Nz(!imgIdAcidoAcetico, 0) = Me.frm_idImagem Or _
Nz(!imgIdShiller, 0) = Me.frm_idImagem Then
' já se encontra utilizada
MsgBox "Já está associada" & vbCrLf _
& "Deverá remover a ligação para atribuir o novo Tipo"
Call logMe("btnAssociarImagem_Click", "Já existe imagem [Normal]" & vbCrLf _
& "Deverá remover a ligação para atribuir o novo Tipo")
Call logMe("btnAssociarImagem_Click", "end")
Exit Sub
End If
End With
With q02_exameSet
.FindFirst "idExame = " & Me.frm_idExame
.Edit
Select Case Nz(Me.frm_imgTipo, 0)
Case 1 ' imagem normal
Forms!frmImagemClassificar.frm_imgNormal.Picture = strImgPath
Me.Parent.frm_imgNormalPath = Nz(strImgPath, "")
Me.Parent.Dirty = False
Me.Parent.Refresh
!imgIdNormal = Nz(Me.frm_idImagem, 0)
Case 2 ' imagem de ácido acético
Forms!frmImagemClassificar.frm_imgAcidoAcetico.Picture = strImgPath
Me.Parent.frm_imgAcidoAceticoPath = Nz(strImgPath, "")
Me.Parent.Dirty = False
Me.Parent.Refresh
!imgIdAcidoAcetico = Nz(Me.frm_idImagem, 0)
Case 3 ' imagem Shiller
Forms!frmImagemClassificar.frm_imgShiller.Picture = strImgPath
Me.Parent.frm_imgShillerPath = Nz(strImgPath, "")
Me.Parent.Dirty = False
Me.Parent.Refresh
!imgIdShiller = Nz(Me.frm_idImagem, 0)
Me.Parent.Dirty = False
Me.Parent.Refresh
Case Else ' apenas se podem associar ao exames os 3 tipos de imagem
MsgBox "Imagem não associável"
.Close
Set q02_exameSet = Nothing
Call logMe("btnAssociarImagem_Click", "end")
Exit Sub
End Select
.Update
.Close
End With
Set q02_exameSet = Nothing
Call logMe("btnAssociarImagem_Click", "end")
Exit Sub
errorTrap:
MsgBox "[btnAssociarImagem_Click]." & "[" & Err.Number & "].[" & Err.Description & "]"
Call logMe("btnAssociarImagem_Click", "errorTrap:" & "[btnAssociarImagem_Click]." & "[" & Err.Number & "].[" & Err.Description & "]")
Resume Next
End Sub
And the Select statement is the update, now with dale's suggestion, but without results.
Of course I can send the database, just let me know
Hope this is enough
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
What should I do? Yes the table is the same (tblExame)
Is writing to the form on the "dirty"? If so, the problem was there before. In the subform I need to update the record that is bound to the main form. What would be your suggestion?
Is writing to the form on the "dirty"? If so, the problem was there before. In the subform I need to update the record that is bound to the main form. What would be your suggestion?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok. I'll give a good look to Gustav's suggestion, but first will try a rethink of the approach. Both the main and subforms may be linked to tables so I may be able to drop DAO altogether and just modify, in code, the form fields.
will let you know
will let you know
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks all for the support. I have changes and cleaned the code and it looks that it is working!
me.parent.txt_SomeField = me.somevalue
me.parent.dirty = false
me.parent.refresh