473,692 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Split Form does not hold Module Variables in Access 2007!!!!

8 New Member
Hi everyone,

First post here!

I have been trying to upgrade to Acc2007 looking forward to using Split Forms.

To my horror I have just discovered that Split Forms do not hold variables at module level!!! Although code is working perfectly well when in Single Form view, when switching to Split Form view... problems. This must definitely be a bug unless there are limitations to Split Forms (doubt it).

Although there might be some workarounds when it comes to normal variables, would there be any workarounds for object variables? I am trying to subclass these forms and without module object variables I don't know how that can be possible!

Please let me know if anyone knows about this. I am too far with upgrading to go back now...

I am attaching a database that recreates this issue and shows how the Current event of the form is not fired through the class when in Split Form view. Change .txt extension to .accdb
Attached Files
File Type: txt CurrentNotFiring.txt (356.0 KB, 953 views)
Aug 21 '09 #1
13 8914
Megalog
378 Recognized Expert Contributor
Funny, my first post here was about split forms too..

Access 2007: Split Forms with Subforms

I'm not sure if you'll get anything helpful out of that thread... I tried your sample database and verified the problem. It could be when you change records, the on current event isnt firing off properly because of the buggy navigation button behavior with split forms.

I'll try your sample db with my Access 2010 copy and see if anything has changed.
Aug 21 '09 #2
geosmy
8 New Member
I saw that post and that's how I found out that Split Forms do not hold module variables. It was very helpful in understanding why this problem occured (the Current event not firing - this is how this issue started) but unforunately I could not see any workarounds.

I tried referring to the Form as Forms!Form1 instead of Me but that didn't work.

If you test in Access 2010 please let me know. I am very interested.
Aug 21 '09 #3
Megalog
378 Recognized Expert Contributor
Geosmy,
Same behavior in A2010.. so no magical fix there..

I did notice that the class code does execute properly if you navigate records using the arrow keys. I think the entire problem is the record selector on the form is bound to the datasheet on the bottom, and not the actual form on top??! Or at least that's how it BEHAVES. It's causing the recordset to move in some manner that doesnt activate the form's events. Very very frustrating...

I have a co-worker who has custom functions that work very well on a datasheet.. he's had the same problem trying to get these functions to work on the datasheet side of a split form. So there's no winning with these!
Aug 21 '09 #4
Megalog
378 Recognized Expert Contributor
You might want to remove the built-in navigation buttons from the form, and put custom nav buttons in the header.. See if that works.
Aug 21 '09 #5
geosmy
8 New Member
Hi Megalog,

I tried disabling the nav buttons and navigate through the datasheet but no luck.

I experimented with the orientation of the form (datasheet top, bottom...) and I noticed that when the nav buttons are attached to the proper form they work properly but when they are attached to the datasheet the problem is still there.

I think that the core of the problem is navigation through the datasheet in any form (either through buttons attaced to the ds or through selecting records from the ds). I can work around the buttons issue by putting the ds on top but a user can at any time select records through the ds (this is the main purpose of the ds in the first place). In the latter case I don't see how custom buttons would work since they would not be attached to the ds but to the main form.

I will keep trying though. Thanks very much for the suggestions. Shocking that Acc2010 has not fixed this though...
Aug 22 '09 #6
Megalog
378 Recognized Expert Contributor
Hrm.... If you have any luck let me know. I was a bit dismayed when I saw they didnt fix any of the problems with the splitforms, or add any new functionality to them in a2010. Although, they have added something called Table Events, which is basically macros tied to the table itself. So, you could have a form that has no coding on it at all, and have the table itself handle the events when the form interacts with it. But I can think of many scenarios where we'd rather have the form do the work.
Aug 24 '09 #7
geosmy
8 New Member
Sounds interesting. Maybe there could be a workaround for my issue (current event not firing in subclassed form) through table events...

When I get hold of access 2010 I will check it out.
Aug 24 '09 #8
Nej Sanerkin
5 New Member
I have had the same difficulty in accessing form module variables in split forms. I have found that if the cursor/focus is in the detail section as opposed to the datasheet the variables are exposed. There seems to be no syntax for moving the focus that I have been able to find, except for F6. In my code I test for the variable and if empty I move the focus by sending - SendKeys "{F6}{F6}", this is grossly inelegent, but needs must.
Sep 17 '10 #9
geosmy
8 New Member
Hi Nej,

To my understanding when access loads a split form it loads two instances of the form. One instance corresponds to the main form and one to the datasheet part. The main form is the main instance (default) on which events such as "On Load" and "On Open" fire at startup.

When focus is on the main form the events that fire (like "OnCurrent" ) correspond to the instance of the main form. Likewise when the focus is on the datasheet the events firing correspond to the datasheet instance. As said earlier on startup (no focus yet) the events of the default instance (main form) fire up.

So when you have a module level variable defined in your split form this will be different for each of the instances (same as if you opened a new instance of SomeForm with New Form_SomeForm - all variables in the new instance will be independent of the original instance).

Now when it comes to the navigation buttons, these seem to belong to the instance of the part of the form on which they are attached to. So if they are attached to the main form the OnCurrent event fires from the main form and when they are attached to the datasheet the OnCurrent fires from there.

You don't even have to change the orientation of the datasheet to see this behaviour. You can play around with the tab key on either part of the form and try to change records from there. The tab key changes the records from the part that you are in at the time.

So what you basically have to do if you are running into problems with this behaviour, is to ensure that your code can deal with both instances (and both their module level variables) seperately and consistently. For instance in my initial example my module level variable was not initialised for the datasheet instance because the "On Load" event would only fire for the main form instance. So all I had to do was at some point to initialise the variable for the datasheet too (along with referring to the form as Me instead of Forms!Form1 to get the right instance - Forms!Form1 seems to make a reference only to the main part of the form!)

You can see all these with the new db I am attaching. Check Form2 and see how the Integer module variable loads and changes with the current event when you change records from the different part of the form (use the tab key).

Hope this helps!
Attached Files
File Type: zip CurrentFiring.zip (97.7 KB, 302 views)
Sep 18 '10 #10

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

Similar topics

1
1072
by: Chris | last post by:
I need to pass a form say 'webform1' in a class file myClass (.vb) and access its web controls say 'txtdisp', ..... My code snippet is : Imports System.Web.UI public class myClass public sub disableitems(ByRef frm as WebForm1) 'Here my intention is to set enabled property of txtdisp to false
1
4229
by: dddsssdddsss | last post by:
A comment and a question To anyone who is using conditional formatting, beware that in Access 2007 the color pallette is not the same as the color pallette in Access 2003. So if you have a particular color you were using as a standard throughout your application, the only way to continue using that color is to code the color. Anyone else notice how forms in Access 2007 display the conditional formatting much slower than in Access...
4
2951
by: Peter | last post by:
Access 2007 optionally opens forms as tabs. There is an Access Option that controls this - Access Options Current Database Document Window Options Tabbed Documents. But how, from VBA, can I programmatically tell whether or not a form is opened in Tabbed or Overlapping mode? I tried using Application.GetOption("Document Window Options")
3
2430
by: dstork | last post by:
Has anyone else experienced Access 2007 crashing when users right click on the subform (with the intention to use the copy feature in the shortcut menu). I went through Allen Browne's recommended checks (Name Autocorrect Options, references, decompiling, etc) and I even tried installing Office SP1 but no luck. (Access also crashes for me when right clicking on the recordsource proptery of a Form). ds
0
1449
by: News Lantic moenie del | last post by:
Hi How can I disable the close button in access 2007. Reason I want to force a backup on exit and now I can't. The code for Access 2003 to disable close button does not work in Access 2007 Thanks Alfred
1
1715
by: gman | last post by:
Is there a way in VB.NET to build a Form/Control as easily as Access 2007 does? I built a small name and address application in Access 2007 and I was surprised at what I was able to do without any code. Access Forms allow a Datasheet (GridView) to show by setting a property (I have mine set to Datasheet on Top). Pretty sweet and easy. I am a seasoned programmer (over 20 years) but I am a newbie to VB.NET 2005. Our company brought in some...
2
1836
by: puT3 | last post by:
Hi, anyone can help me? My problem is data from Form of Asp does not appear in access database when i open the database. Why does this happen? My table name:Cuba ID PK Nama Umur
4
1713
by: simulationguy | last post by:
I inherited an Access 2003 database runs fine in 2003 but in 2007 I get an error on updating a form. Record Not available on the last statement !ItemNumber.SetFocus Does anyone know why Access 2007 is different and any clues on how to get it to work? With Forms!frmMain!frmSKUInput.Form !WhichSKUCombo.Value = "" !WhichSKUList.Value = "" .RecordSource = strSQL1
0
1193
by: GARZAAX | last post by:
Hello; I am in serious need of help. I have a form with subform that I am developing to fill in multiple data on customer orders. the need has come to duplicate up to 10 times the information on the Form and Subform with just the orderID changing. I tried append query with no success because my MS Access program will not recognise the !. line as valid, so i cannot wright to the Tag property. I am now using the SQL statement If...
0
8603
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, 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...
1
8797
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8800
tracyyun
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...
0
7627
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, 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...
1
6459
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5818
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4323
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...
1
2972
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
3
1957
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.