- Sub cmbEnt_NotInList(NewData As String, Response As Integer)
-
-
Answer = MsgBox("add?", vbYesNo, "add?")
-
-
If Answer = vbYes Then
-
-
DoCmd.Close acForm, "frmOrd"
-
CurrentDb().TableDefs("tblOrd").Fields("Ent").RowSource = CurrentDb().TableDefs("tblOrd").Fields("Ent").RowSource & ";" & NewData
-
-
Else
-
-
Response = acDataErrContinue
-
-
End If
-
-
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 -
-
Do While CurrentProject.AllForms("frmOrd").IsLoaded = True
-
DoCmd.Close acForm, "frmOrd"
-
Loop
-
,
and - DoCmd.Close acTable, "tblOrd"
But the problem remains
I'm stumped. Any ideas?
13 3172
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.
It's obvious now you say it! Ill try that now, thanks
- Sub cmbEnt_NotInList(NewData As String, Response As Integer)
-
DoCmd.OpenForm "frmClo"
-
End Sub
- Sub Form_Open(Cancel As Integer)
-
-
Answer = MsgBox("That data inputter is not currently listed. Would you like to add them now?", vbYesNo, "New data inputter?")
-
-
If Answer = vbYes Then
-
-
Dim daodb As DAO.Database
-
Dim daotdfOrd As DAO.TableDef
-
Dim daofldOrd As DAO.Field
-
-
Response = acDataErrAdded
-
DoCmd.Close acForm, "frmOrd"
-
-
Do While CurrentProject.AllForms("frmOrd").IsLoaded = True
-
DoCmd.Close acForm, "frmOrd"
-
Loop
-
-
CurrentDb().TableDefs("tblOrd").Fields("Ent").ValidationRule = CurrentDb().TableDefs("tblOrd").Fields("Ent").ValidationRule & """ & NewData & """
-
daofldEnt.RowSource = daofldEnt.RowSource & ";" & NewData
-
-
Else
-
-
Response = acDataErrContinue
-
-
End If
-
End Sub
-
-
-
results in same error :(
- ...
-
Loop
-
MsgBox (SysCmd(acSysCmdGetObjectState, acTable, "tblOrd"))
-
CurrentDb().TableDefs("tblOrd").Fields("Ent").ValidationRule = CurrentDb().TableDefs("tblOrd").Fields("Ent").ValidationRule & """ & NewData & """
-
...
-
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())
Let me do some testing and I'll get back to you.
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.
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?
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. -
Form1
-
Private Sub but1_Click()
-
DoCmd.OpenForm "Form2", , , , , , Me.NewData
-
DoCmd.Close acForm, "Form1"
-
End Sub
-
-
Form2
-
Private Sub Form_Timer()
-
MsgBox Me.OpenArgs
-
End Sub
-
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.
How do I delete messages lol?! This comment is no longer applicable
What's your code look like now?
Its fixed! I just have to find the right name for the row source property, but thanks for your help!
Its fixed! I just have to find the right name for the row source property, but thanks for your help!
No problem, good luck.
For reference sake:
frmCLOSE: - Sub Form_Open(Cancel As Integer)
-
DoCmd.Close acForm, "frmOrd", acSaveYes
-
End Sub
-
Sub Form_Timer()
-
On Error GoTo ErrorsoExit
-
-
NewData = Left(OpenArgs, InStr(OpenArgs, ";") - 2)
-
Store = Mid(OpenArgs, InStr(OpenArgs, ";") + 2)
-
CurrentDb().TableDefs("tblOrd").Fields("Ent").ValidationRule = CurrentDb().TableDefs("tblOrd").Fields("Ent").ValidationRule & " OR """ & NewData & """"
-
CurrentDb().TableDefs("tblOrd").Fields("Ent").Properties("RowSource") = CurrentDb().TableDefs("tblOrd").Fields("Ent").Properties("RowSource") & ";" & NewData
-
If Store = "" Then DoCmd.OpenForm "frmOrd" Else DoCmd.OpenForm "frmOrd", , , , , , Me.Bookmark = Store
-
DoCmd.Close acForm, "frmCLOSE", acSaveNo
-
ErrorsoExit:
-
End Sub
-
'frm1' -
Sub cmbEnt_NotInList(NewData As String, Response As Integer)
-
-
Response = acDataErrContinue
-
'Question repeats when form is closed unless this line is added
-
Me.cmbEnt.Undo
-
-
Answer = MsgBox("Question?", vbYesNo, "Title?")
-
-
If Answer = vbYes Then
-
-
Dim Store As String
-
-
If Me.NewRecord = False Then Store = Me.Bookmark
-
-
DoCmd.OpenForm "frmCLOSE", , , , , acHidden, NewData & " ; " & Store
-
-
End If
-
-
End Sub
Thanks again to Rabbit
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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'
...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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,...
|
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,...
|
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...
| |