Error:The command or action 'SaveRecord' isn't available now

I

inchong

I converted Acc97 to Acc2003 and got this error "The command or action
'SaveRecord' isn't available now" when i tried to open one form"Add
Info form", which has Save button. I checked "reference" in Tool to
see DAO 3.6 object library setting, and it was right.
How can i resolve this error?
Thanks.
 
H

hmadyson

You will get that message if you are stepping through the code when it hits
docmd.saverecord. As long as you are not stepping through the code, you will
not get this error.

Let me know if this is helpful and if I can provide more assistance.
 
A

Allen Browne

Presumably you have code in the Click event procedure of your button?

We don't know what your code contains, but try this:
If Me.Dirty Then RunCommand acCmdSaveRecord

That should avoid a couple of cases there the error might occur.
 
I

inchong

Code:

Private Sub Save_Button_Click()
On Error GoTo Err_Save_Button_Click

Dim MyDB As Database, MyTable As Recordset
Set MyDB = DBEngine.Workspaces(0).Databases(0)

Dim MyTable4 As Recordset
Set MyTable4 = MyDB.OpenRecordset("Tax Map")
MyTable4.Index = "PrimaryKey"
MyTable4.Seek ">=", Me![Add Tax Map Info SubForm].Form![State
Code], Me![Add Tax Map Info SubForm].Form![COUNTY CODE], Me![Add Tax
Map Info SubForm].Form![TOWNSHIP CODE], Me![Add Tax Map Info
SubForm].Form![Tax Map], Me![Add Tax Map Info SubForm].Form![Alternate
ID]
Do Until MyTable4.EOF Or MyTable4.NoMatch
If MyTable4![State Code] = Me![Add Tax Map Info SubForm].Form!
[State Code] And MyTable4![COUNTY CODE] = Me![Add Tax Map Info
SubForm].Form![County] And MyTable4![TOWNSHIP CODE] = Me![Add Tax Map
Info SubForm].Form![Township] And MyTable4![Tax Map] = Me![Add Tax Map
Info SubForm].Form![Tax Map] And MyTable4![Alternate ID] = Me![Add Tax
Map Info SubForm].Form![AltID] Then
MyTable4.Edit
MyTable4![Title Opinion #] = Me![Add Tax Map Info
SubForm].Form![Title Opinion #]
MyTable4.Update
Exit Do
Else
MyTable4.MoveNext
End If
Loop

Set MyTable = MyDB.OpenRecordset("Interested Parties")
'Stop
MyTable.AddNew
MyTable![LEASE NUMBER] = Forms![LEASE DATA COPY FORM ONLY]!
[LEASE NUMBER]
MyTable![SURFACE#] = "S0000"
MyTable![Division#] = Me![Division]
MyTable![Last Name] = Me![Last Name]
MyTable![First Name] = Me![First Name]
'other things are the same way
MyTable.Update

'SAVE INFORMATION TO THE "INTERESTS/TAX MAP" TABLE FROM THE "NEW
INTEREST TAX MAP SETUP" TABLE
Dim MyTable2 As Recordset, MyTable3 As Recordset
Set MyTable2 = MyDB.OpenRecordset("Interest/Tax Map")
Set MyTable3 = MyDB.OpenRecordset("New Interest Tax Map Setup")
Do Until MyTable3.EOF
MyTable3.MoveFirst
Do Until MyTable3.EOF
If IsNull(MyTable3![State Code]) Then
MyTable3.MoveNext
Else
MyTable2.AddNew
MyTable2![LEASE NUMBER] = MyTable3![LEASE NUMBER]
MyTable2![SURFACE#] = "S0000"
MyTable2![Division#] = MyTable3![Division#]
MyTable2![State Code] = MyTable3![State Code]
'skip other things
MyTable2.Update
MyTable3.MoveNext
End If
Loop

'DELETE ALL RECORDS FROM THE "NEW INTEREST TAX MAP SETUP TABLE
MyTable3.MoveFirst
Do Until MyTable3.EOF
MyTable3.Delete
MyTable3.MoveNext
Loop
Loop
DoCmd.SetWarnings False
'SAVE RECORDS FROM THE "TAX MAP/UNITS Temp" TABLE TO THE "TAX MAP/
UNITS" TABLE
Dim stDocName As String
stDocName = "Append to Tax Map/Units Table"
DoCmd.OpenQuery stDocName, acNormal, acEdit
'DELETE RECORDS FROM THE "TAX MAP/UNITS Temp" TABLE
stDocName = "Delete Tax Map/Units Temp Table"
DoCmd.OpenQuery stDocName, acNormal, acEdit

'SAVE RECORDS FROM THE "TAX MAP/PROSPECTS Temp" TABLE TO THE "TAX MAP/
PROSPECTS" TABLE
stDocName = "Append to Tax Map/Prospects Table"
DoCmd.OpenQuery stDocName, acNormal, acEdit
'DELETE RECORDS FROM THE "TAX MAP/PROSPECTS Temp" TABLE
stDocName = "Delete Tax Map/Prospects Temp Table"
DoCmd.OpenQuery stDocName, acNormal, acEdit

DoCmd.SetWarnings True
DoCmd.Close

Exit_Save_Button_Click:
Exit Sub

Err_Save_Button_Click:
MsgBox Err.DESCRIPTION
Resume Exit_Save_Button_Click

End Sub

where can i add this line?
If Me.Dirty Then RunCommand acCmdSaveRecord
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top