473,320 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 17560
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

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

Similar topics

16
by: Jim Hefferon | last post by:
Hello, I'm getting an error join-ing strings and wonder if someone can explain why the function is behaving this way? If I .join in a string that contains a high character then I get an ascii...
8
by: RC | last post by:
In my Access 2002 form, I have a combo box and on the AfterUpdate event I use DoCmd.RunSQL ("UPDATE .... to update records in a table. When it starts to run I get a message "You are about to...
0
by: Susan Bricker | last post by:
What possible situations (or set of variables) could cause the following error: "The command or action 'DeleteRecord' isn't available now." Error Number = 2046. The routine that gets the...
5
by: Stan | last post by:
When I create a Web project and then try to add the files to it (Add Existing Item), I get this error message "The folder http://localhost/FinWeb is no longer availabe" In fact the folder and...
1
by: Elie | last post by:
Hello I get this error when the code runs from the server as an .asp page or from a compiled dll. But When I log onto the server and run a vb program that executes the same code, it works...
9
by: Martin Eyles | last post by:
Hi, I have set up an asp.net website on another PC in order to test it. The site was fine on my PC, but on the new PC all the pages give the error "The Page Cannot Be Found". Some legacy pages...
0
by: Curious | last post by:
Hi, I'm not sure if this is the right place to post such command issues. If you know a better forum where people respond to messages fairly often, please let me know! Anyway, would appreciate...
1
by: LiveCycle | last post by:
Hi, I've got a longstanding project that's been working fine for about a year. I was working on one of the pages, a simple download page. After making a little tweak on the page, I tried to...
15
by: Kurda Yon | last post by:
Hi, I try to "build" and "install" pysqlite? After I type "python setup.py build" I get a lot of error messages? The first error is "src/ connection.h:33:21: error: sqlite3.h: No such file or...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.