473,405 Members | 2,187 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,405 software developers and data experts.

3422 error when modifying table from form

Expand|Select|Wrap|Line Numbers
  1. Sub cmbEnt_NotInList(NewData As String, Response As Integer)
  2.  
  3.  Answer = MsgBox("add?", vbYesNo, "add?")
  4.  
  5.  If Answer = vbYes Then
  6.  
  7.   DoCmd.Close acForm, "frmOrd"
  8.   CurrentDb().TableDefs("tblOrd").Fields("Ent").RowSource = CurrentDb().TableDefs("tblOrd").Fields("Ent").RowSource & ";" & NewData
  9.  
  10.  Else
  11.  
  12.   Response = acDataErrContinue
  13.  
  14.  End If
  15.  
  16. End Sub  
There's more code but Im only giving the relevant bits. I know I can modify rowsource in the form, but now I'm stuck wondering why when I try and modify the table I get a 3422 error (Cannot modify table structure. Another user has the table open.) after Ive closed the form. There are no other forms/queries/reports/etc open. The only thing I can think of is that the form hasn't disconnected properly from the table; I've tried
Expand|Select|Wrap|Line Numbers
  1.  
  2. Do While CurrentProject.AllForms("frmOrd").IsLoaded = True
  3.     DoCmd.Close acForm, "frmOrd"
  4. Loop
  5.  
,
and
Expand|Select|Wrap|Line Numbers
  1.   DoCmd.Close acTable, "tblOrd"
But the problem remains

I'm stumped. Any ideas?
Oct 23 '07 #1
13 3172
Rabbit
12,516 Expert Mod 8TB
I'm guessing that this event is being triggered while you're in the form. And while the event is still running, then the form is still open. Have an intermediary form whose On Open event is to close the form and then make the changes and then close itself. See if that works.
Oct 23 '07 #2
It's obvious now you say it! Ill try that now, thanks
Oct 23 '07 #3
Expand|Select|Wrap|Line Numbers
  1. Sub cmbEnt_NotInList(NewData As String, Response As Integer)
  2.  DoCmd.OpenForm "frmClo"
  3. End Sub
Expand|Select|Wrap|Line Numbers
  1.  Sub Form_Open(Cancel As Integer) 
  2.  
  3.  Answer = MsgBox("That data inputter is not currently listed.  Would you like to add them now?", vbYesNo, "New data inputter?")
  4.  
  5.  If Answer = vbYes Then
  6.  
  7.   Dim daodb As DAO.Database
  8.   Dim daotdfOrd As DAO.TableDef
  9.   Dim daofldOrd As DAO.Field
  10.  
  11.   Response = acDataErrAdded
  12.   DoCmd.Close acForm, "frmOrd"
  13.  
  14.   Do While CurrentProject.AllForms("frmOrd").IsLoaded = True
  15.     DoCmd.Close acForm, "frmOrd"
  16.   Loop
  17.  
  18.   CurrentDb().TableDefs("tblOrd").Fields("Ent").ValidationRule = CurrentDb().TableDefs("tblOrd").Fields("Ent").ValidationRule & """ & NewData & """
  19.   daofldEnt.RowSource = daofldEnt.RowSource & ";" & NewData
  20.  
  21.  Else
  22.  
  23.   Response = acDataErrContinue
  24.  
  25.  End If
  26. End Sub
  27.  
  28.  
  29.  
results in same error :(
Oct 23 '07 #4
Expand|Select|Wrap|Line Numbers
  1.  ...  
  2. Loop
  3. MsgBox (SysCmd(acSysCmdGetObjectState, acTable, "tblOrd"))
  4.   CurrentDb().TableDefs("tblOrd").Fields("Ent").ValidationRule = CurrentDb().TableDefs("tblOrd").Fields("Ent").ValidationRule & """ & NewData & """
  5. ...
  6.  
Gives 0, ie, the table is closed. So I assume it's something to do with the code (it gives an error at the line starting CurrentDb())
Oct 23 '07 #5
Rabbit
12,516 Expert Mod 8TB
Let me do some testing and I'll get back to you.
Oct 23 '07 #6
Rabbit
12,516 Expert Mod 8TB
Ok. You're going to have to break the chain of events.
Put the code in the timer event. Set the timer interval to 1000. Close the form in an event other than the timer event.

A note of caution though, I ran into trouble with quotation marks. I could run the code once but on the second time around there was an error. I'm still trying to work that part out.
Oct 23 '07 #7
When you say put the close event in another event, do you mean call it from timer?

Also, the rowsource has the newdata (from NotInList event) added to it. How can I pass this onto the timer event?
Oct 23 '07 #8
Rabbit
12,516 Expert Mod 8TB
When you say put the close event in another event, do you mean call it from timer?

Also, the rowsource has the newdata (from NotInList event) added to it. How can I pass this onto the timer event?
What I mean was to just keep the Close event in the Open Form event or the original event you had it in. And then in the Timer event you modify the structure.

You can pass the value of the new data through the OpenArgs parameter of the OpenForm.

Expand|Select|Wrap|Line Numbers
  1. Form1
  2. Private Sub but1_Click()
  3.    DoCmd.OpenForm "Form2", , , , , , Me.NewData
  4.    DoCmd.Close acForm, "Form1"
  5. End Sub
  6.  
  7. Form2
  8. Private Sub Form_Timer()
  9.    MsgBox Me.OpenArgs
  10. End Sub
  11.  
I'm still having problems with the quotes. So even after you get through to modifying the table structure, you might run into trouble with the quotes.
Oct 23 '07 #9
How do I delete messages lol?! This comment is no longer applicable
Oct 23 '07 #10
Rabbit
12,516 Expert Mod 8TB
What's your code look like now?
Oct 23 '07 #11
Its fixed! I just have to find the right name for the row source property, but thanks for your help!
Oct 23 '07 #12
Rabbit
12,516 Expert Mod 8TB
Its fixed! I just have to find the right name for the row source property, but thanks for your help!
No problem, good luck.
Oct 23 '07 #13
For reference sake:
frmCLOSE:
Expand|Select|Wrap|Line Numbers
  1.  Sub Form_Open(Cancel As Integer)
  2. DoCmd.Close acForm, "frmOrd", acSaveYes
  3. End Sub
  4. Sub Form_Timer()
  5. On Error GoTo ErrorsoExit
  6.  
  7. NewData = Left(OpenArgs, InStr(OpenArgs, ";") - 2)
  8. Store = Mid(OpenArgs, InStr(OpenArgs, ";") + 2)
  9. CurrentDb().TableDefs("tblOrd").Fields("Ent").ValidationRule = CurrentDb().TableDefs("tblOrd").Fields("Ent").ValidationRule & " OR """ & NewData & """"
  10. CurrentDb().TableDefs("tblOrd").Fields("Ent").Properties("RowSource") = CurrentDb().TableDefs("tblOrd").Fields("Ent").Properties("RowSource") & ";" & NewData
  11. If Store = "" Then DoCmd.OpenForm "frmOrd" Else DoCmd.OpenForm "frmOrd", , , , , , Me.Bookmark = Store
  12. DoCmd.Close acForm, "frmCLOSE", acSaveNo
  13. ErrorsoExit:
  14. End Sub
  15.  
'frm1'
Expand|Select|Wrap|Line Numbers
  1. Sub cmbEnt_NotInList(NewData As String, Response As Integer)
  2.  
  3. Response = acDataErrContinue
  4. 'Question repeats when form is closed unless this line is added
  5. Me.cmbEnt.Undo
  6.  
  7. Answer = MsgBox("Question?", vbYesNo, "Title?")
  8.  
  9. If Answer = vbYes Then
  10.  
  11. Dim Store As String
  12.  
  13. If Me.NewRecord = False Then Store = Me.Bookmark
  14.  
  15. DoCmd.OpenForm "frmCLOSE", , , , , acHidden, NewData & " ; " & Store
  16.  
  17. End If
  18.  
  19. End Sub

Thanks again to Rabbit
Oct 24 '07 #14

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

Similar topics

2
by: Scott_From_PA | last post by:
I have a love hate thing going with Dreamweaver! One of the things I absolutely hate is the properties box when modifying form objects. Lets say you lay out a form in a table and it comes time...
4
by: Bryan Tang | last post by:
I built an ASP to search the content in index server. It is ok if search in English. Whenever I search in Chinese, I will got the following error message, CreateRecordset ?u?~ '80004005' ...
2
by: Alex Wisnoski | last post by:
I have an A97 application that I am modifying. I have created an unbound form, "zfrmTestEnterPlacements", with a subform, "zsfrmSelectPlacement". The intent is to use a combo box on the primary...
3
by: Nathan Bloomfield | last post by:
Hi there, I am having difficulty with a piece of code which would work wonders for my application if only the error trapping worked properly. Basically, it works as follows: - adds records...
3
by: rivka.howley | last post by:
I recently added some code to the BeforeUpdate event of a text box on a form. The code uses the new value in the text box to recalculate some values in another table, which is shown in a subform on...
0
by: Jeff Dockman | last post by:
Background: We needed the ability to create a templated web site that may change in layout from installation to installation. To accomplish this, we created a base Page class that all pages in...
4
by: vg-mail | last post by:
Hello all, I have identical design for form and report but I am getting calculation error on form and everything is OK on report. The form and report are build up on SQL statement. The...
2
by: PhilOwens | last post by:
Morning/Afternoon all, Having slight problem with showing users the progress of a query..... Bit of background....The database allows users to view the status of documents i.e. Completion date,...
11
by: fniles | last post by:
One of our application uses VB6 and Access97 database. Another application uses VB.NET 2005. This morning for about 15 seconds when the application tries to read either a query or a table from the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.