Hi
WinXPPro
Access 2002
There a couple of threads on here mentioning the following error but none seem to apply to my situation?
I have a form where a user can create an Estimate for a job. Once the job is completed they can click a button on the Estimate Form to create an Invoice based on that Estimate. I want the new Invoice to pop up to the user immediately after it has been created. However I get the following error.
"Run-time error '3008': The table 'Invoices' is already opened exclusively by another user, or it is already open through the user interface and cannot be manipulated programmatically."
My code looks like this.
-------------------------------------------------------
Dim rsWrite As New Recordset
rsWrite.Open "Invoices", CurrentProject.AccessConnection, adOpenDynamic, adLockOptimistic
rsWrite.AddNew
rsWrite!Invoice_Number = New_Rec_No
rsWrite!Date_Invoice_Added_to_System = Date & " " & Time
rsWrite.Update
New_Rec_ID = rsWrite!Invoice_ID
rsWrite.Close
stDocName = "Invoice Details Form"
If Not IsLoaded(stDocName) = True Then
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
Forms("Invoice Details Form").Recordset.FindFirst "Invoice_ID = " & New_Rec_id
Forms("Invoice Details Form").SetFocus
-----------------------------------------------------------
It seems I have to "close" the Invoices table somehow? I tried CurrentProject.AccessConnection.close after the rsWrite.close but that did not work.
Can anyone help me please?
Thanks
WinXPPro
Access 2002
There a couple of threads on here mentioning the following error but none seem to apply to my situation?
I have a form where a user can create an Estimate for a job. Once the job is completed they can click a button on the Estimate Form to create an Invoice based on that Estimate. I want the new Invoice to pop up to the user immediately after it has been created. However I get the following error.
"Run-time error '3008': The table 'Invoices' is already opened exclusively by another user, or it is already open through the user interface and cannot be manipulated programmatically."
My code looks like this.
-------------------------------------------------------
Dim rsWrite As New Recordset
rsWrite.Open "Invoices", CurrentProject.AccessConnection, adOpenDynamic, adLockOptimistic
rsWrite.AddNew
rsWrite!Invoice_Number = New_Rec_No
rsWrite!Date_Invoice_Added_to_System = Date & " " & Time
rsWrite.Update
New_Rec_ID = rsWrite!Invoice_ID
rsWrite.Close
stDocName = "Invoice Details Form"
If Not IsLoaded(stDocName) = True Then
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
Forms("Invoice Details Form").Recordset.FindFirst "Invoice_ID = " & New_Rec_id
Forms("Invoice Details Form").SetFocus
-----------------------------------------------------------
It seems I have to "close" the Invoices table somehow? I tried CurrentProject.AccessConnection.close after the rsWrite.close but that did not work.
Can anyone help me please?
Thanks