I have a situation where there may be no table for a form; on error, the table is rebuilt and all is good; except to open the form, I have to click the form again. I tried
but nothing happens. I think its because the form is already open, with the Sub form_OnError. But if I try and close the form, it crashes access and I get asked to send an error report, because the code is running from the form presumably. So how do I get round it? I've tried another form, which if it isn't called from the error works fine. I've tried to run the close function from another sub, and another macro, but every time I try and close the form where the error occurs it fails
42 3415 Lysander 344
Recognized Expert Contributor
I have a situation where there may be no table for a form; on error, the table is rebuilt and all is good; except to open the form, I have to click the form again. I tried
but nothing happens. I think its because the form is already open, with the Sub form_OnError. But if I try and close the form, it crashes access and I get asked to send an error report, because the code is running from the form presumably. So how do I get round it? I've tried another form, which if it isn't called from the error works fine. I've tried to run the close function from another sub, and another macro, but every time I try and close the form where the error occurs it fails
I haven't tried this, but, if the form is already open, and having rebuilt the table within your error handling process, try me.requery or me.refresh so that the open form tries again to access your data
It opens in design mode the first time I edit the vba, but after that the result is the same. Click, and no form opens.
MMcCarthy 14,534
Recognized Expert Moderator MVP
In the Sub form_OnError code add the line. - DoCmd.Close acForm, "frmCSN"
Mary
In the Sub form_OnError code add the line. - DoCmd.Close acForm, "frmCSN"
Mary
I tried that but nothing happens (see first post) :(
MMcCarthy 14,534
Recognized Expert Moderator MVP
I tried that but nothing happens (see first post) :(
In what event have you got the code checking if the table exists?
form on error. When I try and open the form without a table associated I get an error saying to effect the table does not exist. I think I tried it under form load, but I still got the error
The code is
If dataerr = (the error code) Then
Build Table
Response = acDataErrContin ue
End If
MMcCarthy 14,534
Recognized Expert Moderator MVP
form on error. When I try and open the form without a table associated I get an error saying to effect the table does not exist. I think I tried it under form load, but I still got the error
The code is
If dataerr = (the error code) Then
Build Table
Response = acDataErrContin ue
End If
And where exactly did you put the form close in this code.
If dataerr = (the error code) Then
Build Table
[font=Arial]DoCmd.OpenForm "frmCSN"[/font]
Response = acDataErrContin ue
End If
T'was at the end of the build table code. I also tried to launch another form and reopen frmCSN from there, without success.
MMcCarthy 14,534
Recognized Expert Moderator MVP
You need to close the form. Then build the table and then open the form again but you can't do that in the Form_Error event because once you close the form the code is no longer in focus. -
Private Sub Form_Error()
-
-
If dataerr = (the error code) Then
-
call noTable
-
End If
-
-
End Sub
-
-
Sub noTable()
-
-
DoCmd.Close acForm, "frmCSN"
-
Build Table
-
DoCmd.OpenForm "frmCSN"
-
Response = acDataErrContinue ' not sure how to cater for this as you haven't given me that part of the code
-
-
End Sub
-
Mary
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: MLH |
last post by:
If you have these lines in code on MyForm1...
DoCmd OpenForm "MyForm2`"
MsgBox "I opened MyForm2"
Is it #ALWAYS# true that all form events
on MyForm2 will occur before the MsgBox
statement in MyForm1 is processed?
Is there ever an exception that might create
|
by: Lyn |
last post by:
Hi, this has been driving me nuts. I'm on Office 2003 SP1, Win XP SP1.
I am opening a form with a number of subforms based on various tables. The
subforms are populated via the main form's Current event. I am using
similar code to open each of the subforms successfully -- except for this
one case which gives the above error.
I have simplified the SQL to its most basic level. It runs just fine as a
query. I just can't make it work...
|
by: Jim Evans |
last post by:
Using code and suggestions from an earkier thread in this group, I have
created the following cond for the open event of a form I am opening from
the button click event of another form.
Private Sub Form_Open(Cancel As Integer)
If Len(Me.OpenArgs & "") > 0 Then
Dim i As Integer
Dim s As String
|
by: Rolan |
last post by:
I need assistance regarding code needed to prevent someone from opening
a form if a table field name(s) has been changed. For example, there is
existing code to check for certain data based on DLookup in a table
before a form can be opened. If one changes the field name in the
table, then the verification check is bypassed. So adding code to
DLookup to check for the existence of specific field names first is
necessary. Any insight will be...
|
by: Norm |
last post by:
I must not be understanding something about the use of forms in VB.Net that
is different from VB. I have one form running in the background with an icon
in the task bar. Right clicking on the icon gives you a list of options, one
of which is to show an About form. After this form shows I get an error
saying "Object reference not set to an instance of the object." I have tried
opening the form with
frmAbout.Show
frmAbout.ShowDialog
| |
by: MartinR |
last post by:
Hi,
I'm still new to writing code in vba as I've only been introduced to
access three weeks ago. I have written this code below and it executes
but does not do what I want it to do. What I want is the form
"Sparesform" to open when I double click on the "index" field for the
record I wish to view. The index field is part of a subform. What is
happening at the moment is the form "Sparesform" is opening but does
not go to the correct record...
|
by: frenchy |
last post by:
I am getting this error in Adobe after struggling with a 'submit'
button on an acrobat form that is in production and all the other
appdev people in the office are NOT having a problem with. It submits
the form to the web successfully for them, for me the button just
clicks and does nothing. So we turned on my javascript debug in Adobe
and are getting this?
Acrobat EScript Built-in Functions Version 6.0
Acrobat Annotations /...
|
by: Coll |
last post by:
I have a form with a subform on it. On my main form, you select an
employee id number and the top portion of form fills in with data, and
the bottom portion of the form,which is a subform, lists existing
records there are for that employee (one to many relationship). How
can I set up my main form, so the user can select one of the records
on the subform and retain that recordid number for use in opening a
new form and displaying the that...
|
by: martin DH |
last post by:
**Urgent Need**
I'll throw out the basics and any assistance is very, very, very much appreciated!
Access 2003 on XP
On a form (frmMain) is an option group of check boxes (ReportFrame) from which a user can choose a specific report to generate. The user selects the report of choice then presses a comand button (CmdRunRpt). The command button runs using the code below:
Private Sub CmdRunRpt_Click()
If ReportFrame = 1 Then...
|
by: angi35 |
last post by:
Hi - In Access 2000, I'm trying to create a switchboard so users can open a certain form with different filters. I thought I would use an option group with toggle buttons. I suppose it could be just a series of command buttons instead. Either way, I can't figure out the code to get Access to both open a form and filter it at the same time.
Part of my trouble is also that the terms I need to filter on are multiple words, and I'm really...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |