Delete a record

L'apprentis

Redcifer
Local time
Today, 10:57
Joined
Jun 22, 2005
Messages
177
I have a problem with 1 of my form (FrmEditDrawing) that I use to edit a specific record from 1 of my table (TblDrawing). The user will see the Data for each drawing on a form that I called (FrmViewDrawing) and will be able to edit the data for each drawing by clicking a button that will open the form "FrmEditDrawing" on the specific record. In that case I can't edit and change the data for any fields but if I open the form on its own, I can edit and change the data ?
I guess it has something to do with the fact that I open twice the same recordsets which locks the table, I am not sure. What would be the different option to solve this problem?
 
Can you post the code that is behind the button on FrmViewDrawing that opens FrmEditDrawing. The subject of your post indicates you wish to do more than just edit the record. Is that true?
 
Hi rural guy,
Here is the code for the button (I have used the wizzard)

Code:
Private Sub CmdEditDrawing_Click()
On Error GoTo Err_CmdEditDrawing_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "FrmEditDrawingFile"
    
    stLinkCriteria = "[DrawingFileID]=" & Me![TxtDrawingFileID]
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    Forms.FrmDrawingFile.SetFocus
    DoCmd.Close

Exit_CmdEditDrawing_Click:
    Exit Sub

Err_CmdEditDrawing_Click:
    MsgBox Err.Description
    Resume Exit_CmdEditDrawing_Click
    
End Sub

I don't know if it can help to understand but here are the rowsource for the 2 forms:

(FrmDrawingFile)
SELECT TblDrawingFile.DrawingFileID, TblDrawingFile.DrawingFile, TblDrawingFile.AssemblyFamily, TblDrawingFile.Drawingtype, TblDrawingFile.ShoulderLength, TblDrawingFile.CADHyperlink, TblPipe.PipeSize
FROM TblPipe RIGHT JOIN TblDrawingFile ON TblPipe.PipeId = TblDrawingFile.PipeID
ORDER BY TblDrawingFile.DrawingFile;


(FrmEditFile)
SELECT TblDrawingFile.DrawingFile, TblDrawingFile.AssemblyFamily, TblDrawingFile.Drawingtype, TblDrawingFile.ShoulderLength, TblDrawingFile.CADHyperlink, TblPipe.PipeSize, TblDrawingFile.DrawingFileID FROM TblPipe RIGHT JOIN TblDrawingFile ON TblPipe.PipeId=TblDrawingFile.PipeID;

Thanks again,
 
I see nothing in the code to keep you from editing the record in the FrmEditDrawingFile form.
Why do you have the following line in the code? Forms.FrmDrawingFile.SetFocus
How do you have the RecordLocks set on each form?
 
Oh, yeah...

Forms.FrmDrawingFile.SetFocus
Docmd.Close

I have added this 2 line after to see if it would still not work when the form for viewing the record was closed for the editing.
The first form as the records locked to avoid any changes and the 2nd form as the record not locked to allow editing.
 
On the data tab of the properties sheet for the form is a property called RecordLocks. This property is to keep *other* users from editing the record while the form has it open. If you have this set to other than "NoLocks" on the first form then change it to "NoLocks" and test again. Post back with your results.
 
Rural Guys,
your suggestion is correct, if the first form is set to no locks as well as in the 2nd form. I can edit the data, I thought that by closing the "viewing Form" (with the property set to record locked )the the table wouldn't stay locked..was wrong...Thank you again rural guy.
 
You are welcome. It might have worked if you had closed the first form before opening the second form. The code in the first form will continue to execute even though the form has been "Closed". You just can not reference the first form any longer.
 

Users who are viewing this thread

Back
Top Bottom