469,352 Members | 2,054 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,352 developers. It's quick & easy.

error "The command or action 'SaveRecord' isn't available now"

6
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.
Mar 29 '07 #1
12 16979
MMcCarthy
14,534 Expert Mod 8TB
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.
What code exactly are you using on the save record button.
Mar 29 '07 #2
ilucks
6
What code exactly are you using on the save record button.
Clickevent and commandbutton - Save button

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

Expand|Select|Wrap|Line Numbers
  1. Private Sub Save_Button_Click()
  2. On Error GoTo Err_Save_Button_Click
  3.  
  4.   Dim MyDB As Database, MyTable As Recordset
  5.   Set MyDB = DBEngine.Workspaces(0).Databases(0)
  6.  
  7.     Dim MyTable4 As Recordset
  8.     Set MyTable4 = MyDB.OpenRecordset("Tax Map")
  9.     MyTable4.Index = "PrimaryKey"
  10.     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]
  11.     Do Until MyTable4.EOF Or MyTable4.NoMatch
  12.     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
  13.         MyTable4.Edit
  14.         MyTable4![Title Opinion #] = Me![Add Tax Map Info SubForm].Form![Title Opinion #]
  15.         MyTable4.Update
  16.         Exit Do
  17.     Else
  18.         MyTable4.MoveNext
  19.     End If
  20.     Loop
  21.  
  22.   Set MyTable = MyDB.OpenRecordset("Interested Parties")
  23. 'Stop
  24.     MyTable.AddNew
  25.         MyTable![LEASE NUMBER] = Forms![LEASE DATA COPY FORM ONLY]![LEASE NUMBER]
  26.         MyTable![SURFACE#] = "S0000"
  27.         MyTable![Division#] = Me![Division]
  28.         MyTable![Last Name] = Me![Last Name]
  29.         MyTable![First Name] = Me![First Name]
  30.         'other things are the same way
  31.     MyTable.Update        
  32.  
  33. 'SAVE INFORMATION TO THE "INTERESTS/TAX MAP" TABLE FROM THE "NEW INTEREST TAX MAP SETUP" TABLE
  34.     Dim MyTable2 As Recordset, MyTable3 As Recordset
  35.     Set MyTable2 = MyDB.OpenRecordset("Interest/Tax Map")
  36.     Set MyTable3 = MyDB.OpenRecordset("New Interest Tax Map Setup")
  37.     Do Until MyTable3.EOF
  38.     MyTable3.MoveFirst
  39.         Do Until MyTable3.EOF
  40.         If IsNull(MyTable3![State Code]) Then
  41.             MyTable3.MoveNext
  42.         Else
  43.  MyTable2.AddNew
  44.             MyTable2![LEASE NUMBER] = MyTable3![LEASE NUMBER]
  45.             MyTable2![SURFACE#] = "S0000"
  46.             MyTable2![Division#] = MyTable3![Division#]
  47.             MyTable2![State Code] = MyTable3![State Code]
  48.             'skip other things 
  49.             MyTable2.Update
  50.             MyTable3.MoveNext
  51.         End If
  52.         Loop 
  53.  
  54. 'DELETE ALL RECORDS FROM THE "NEW INTEREST TAX MAP SETUP TABLE
  55.     MyTable3.MoveFirst
  56.     Do Until MyTable3.EOF
  57.         MyTable3.Delete
  58.         MyTable3.MoveNext
  59.     Loop
  60.     Loop
  61.  DoCmd.SetWarnings False
  62.  'SAVE RECORDS FROM THE "TAX MAP/UNITS Temp" TABLE TO THE "TAX MAP/UNITS" TABLE
  63.     Dim stDocName As String
  64.     stDocName = "Append to Tax Map/Units Table"
  65.     DoCmd.OpenQuery stDocName, acNormal, acEdit
  66.  'DELETE RECORDS FROM THE "TAX MAP/UNITS Temp" TABLE
  67.     stDocName = "Delete Tax Map/Units Temp Table"
  68.     DoCmd.OpenQuery stDocName, acNormal, acEdit
  69.  
  70. 'SAVE RECORDS FROM THE "TAX MAP/PROSPECTS Temp" TABLE TO THE "TAX MAP/PROSPECTS" TABLE
  71.     stDocName = "Append to Tax Map/Prospects Table"
  72.     DoCmd.OpenQuery stDocName, acNormal, acEdit
  73. 'DELETE RECORDS FROM THE "TAX MAP/PROSPECTS Temp" TABLE
  74.     stDocName = "Delete Tax Map/Prospects Temp Table"
  75.     DoCmd.OpenQuery stDocName, acNormal, acEdit
  76.  
  77. DoCmd.SetWarnings True
  78. DoCmd.Close
  79.  
  80. Exit_Save_Button_Click:
  81.     Exit Sub
  82.  
  83. Err_Save_Button_Click:
  84.     MsgBox Err.DESCRIPTION
  85.     Resume Exit_Save_Button_Click
  86.  
  87. End Sub
  88.  
Thanks.
Mar 30 '07 #3
MMcCarthy
14,534 Expert Mod 8TB
Clickevent and commandbutton - Save button

where can i add this line in the code?
If Me.Dirty Then RunCommand acCmdSaveRecord
I'm not sure what you mean. The code you have given uses recordsets to save data. The line of code above would save a record if any changes had been made on a form. However, this would happen automatically on a bound form.

Mary
Apr 1 '07 #4
ilucks
6
Thank you for your tip.

I have a few more questions about it.
As i mentioned before, i converted this DB to access 2002 and tried to open an unbound form from the bound form.
so like this. I have
1. open a bound form A ( Customer)
2. enter a customer number and click Add info button,which is an unbound form to add more information. Here is the problem occurred.
It says error "The command or action 'SaveRecord' isn't available now"
can you tell me about more how this happenning in the bound or unbound form?
you're saying that the code in Add Info form(unbound) shouldn't cause this error.
what about in Form A? by the way, a user
why does this happen?
how does a subform work after the conversion?
i just noticed that a subform(bound form) in Form A displays just like a normal form. In other words, i checked the properties of this subform and it doesn't say subform propeties.just says "Form".



i am a beginner in access programming.
I would appreciaste your help.
Apr 2 '07 #5
MMcCarthy
14,534 Expert Mod 8TB
Bound forms are bound to a table or query and will save records and changes to records directly to the tables. An unbound form is just a visual graphic. The data is only held as long as the form is open.

You have tried to get around this by adding the data via recordsets but if you are trying to tie that new record in the bound form then this won't work as this record is not yet saved.

Why is the second form unbound?

Using subforms there is a Form that the object is based on and a subform object which is the object on the Main Form.

Mary
Apr 2 '07 #6
ilucks
6
Bound forms are bound to a table or query and will save records and changes to records directly to the tables. An unbound form is just a visual graphic. The data is only held as long as the form is open.

You have tried to get around this by adding the data via recordsets but if you are trying to tie that new record in the bound form then this won't work as this record is not yet saved.

Why is the second form unbound?

Using subforms there is a Form that the object is based on and a subform object which is the object on the Main Form.

Mary
Why is the second form unbound?
it was like this before i came to work here..
When does this error happen?
The DB in access 97 works fine, but not the converted one, why?
I checked other forms and they just display data.
This is the only form has a savebutton but you told me the code uses recordset to save data. where else do i have to check?

thanks
Apr 2 '07 #7
MMcCarthy
14,534 Expert Mod 8TB
What the unbound form is doing is not incorrect but it's very difficult to guide you through a conversion as your knowledge of VBA is limited.

There is no save command as such in this code which means the error is probably referring to one of the recordset update commands. I don't know why it's not working as there are many possibilities which could extend to the queries.

When the error comes up, do you get a debug option? If so what line of code does it stop at?

Mary
Apr 2 '07 #8
ilucks
6
What the unbound form is doing is not incorrect but it's very difficult to guide you through a conversion as your knowledge of VBA is limited.

There is no save command as such in this code which means the error is probably referring to one of the recordset update commands. I don't know why it's not working as there are many possibilities which could extend to the queries.

When the error comes up, do you get a debug option? If so what line of code does it stop at?

Mary
No, i didn't get the debug option.
In the bound form(Form A), i get this message when i click Add Info button.
By the way, i found out that this Add Info form has two bound forms associated with.lol
Again,
1. i open Form A(the bound form)
2. click Add Info button to add additional info - i get an error message
what is If Me.Dirty then Me.Dirty = false
when can i use and how?
What is this?
If Me.Dirty Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Thank you much
End If
Apr 2 '07 #9
MMcCarthy
14,534 Expert Mod 8TB
No, i didn't get the debug option.
In the bound form(Form A), i get this message when i click Add Info button.
By the way, i found out that this Add Info form has two bound forms associated with.lol
Again,
1. i open Form A(the bound form)
2. click Add Info button to add additional info - i get an error message
what is If Me.Dirty then Me.Dirty = false
when can i use and how?
This clears the form of any new or edited data.

What is this?
If Me.Dirty Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
This says if changes have been made then save the record. However, this won't work on an unbound form.
Apr 2 '07 #10
sierra7
446 Expert 256MB
Hi
I have just the same error message in similar circumstances; forms that run ok in '97 but error after conversion to 2002/3, so thought I'd add to this thread.

My situation is that after opening the [Sales Order History] listing form the user can pop-open the main [Sales Orders] in READ ONLY format which is when the error occurs. Microsoft's reason is ;-

"Access 2000 only looks at the AllowEdits property when making this determination, when it should be looking at both the AllowEdits and the AllowAdditions properties." - kb 280521 (similar but not same problem)

Microsoft's recommendation was to load latest Service Pack but that did not work for me so I changed the code as below.
Expand|Select|Wrap|Line Numbers
  1.    stDocName = "SalesOrders"    
  2.   stCalledFrom = "Previous"
  3.   stLinkCriteria = "[OrderID]=" & Me![OrderID]
  4.  
  5.   DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormReadOnly, acDialog
  6.  
  7. 'change last line to 
  8.   DoCmd.OpenForm stDocName, , , stLinkCriteria, , acDialog
I tried to hold off the save if nothing had changed with ;-
Expand|Select|Wrap|Line Numbers
  1. If Me.Dirty Then DoCmd.RunCommand acCmdSaveRecord
but that did not work even though the form itself should not have been 'dirty'. When witing the code I think I had to force a 'save' to keep various audit functions current (because it is some years since I wrote this)

S7
Jan 14 '08 #11
DonRayner
489 Expert 256MB
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.
I have the same problem with some of my forms. I'm using the same form for Adding / Editing / Viewing records with subforms on a tab control. The subforms are linked to different tables that link back to the main table. The save command has to be in there for when adding new records so that records don't get saved into the tables without the the main table being saved.

I just got around the problem by trapping the error.

Public Sub (YourSubName)
On Error GoTo ErrPoint

Your code goes here

ExitPoint:
Exit Sub

ErrPoint:
If Err.Number = 2046 Then
Resume Next
Else
MsgBox "Error# " & err.number & " " & Err.Description
Resume ExitPoint
End If

You can use whatever code you want in place of the MsgBox, I personally call my own error traping sub form there that places all the error information into a table so I can use it for debuging later.

Don
Sep 10 '08 #12
I was running into the same issue.

I think I've figured it out. At least for me. I did a quick check and it seems that if your FORM is going after more than 1 table it doesn't know where to save the info. So I'm trying a work around. Creating a table with all data fields active with no links or relationships.

Hope it works for you guys too.

~Bill
Feb 3 '17 #13

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

16 posts views Thread by Jim Hefferon | last post: by
9 posts views Thread by Martin Eyles | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.