473,419 Members | 1,839 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,419 software developers and data experts.

Access Form Load-Active-Current Code Execution Issue

I have an access database that I am developing for use each day. I am a relatively inexperienced vba user, so I am using/reusing a lot of code that I have developed for specific tasks, learning new material, and integrating code I am finding that fits specific needs from the internet from various sights (yes I understand the risks associated with this)

The issue I am having is related to code executing when my main form is being loaded. I have a large number of things that happen: text box back colors standardize to grey, command button captions change, network drives are mapped, file objects are checked for last modified date and written into a table....

When I put the code on a command button, it all works perfectly. When I put it in the form Load or form Current, it throws runtime 2475 indicating that the form has to be active for the "strFormName = Screen.ActiveForm.Name" to be used. While it seems obvious, I can't seem to figure out which event that I can put this in that will still work...otherwise I need to change the code so that it will somehow work.

code snippet ---
Expand|Select|Wrap|Line Numbers
  1. Georeport = Array("BRAZIL", "CANADA", "MEXICO", "SSA", "UNITED_STATES")
  2. intcounter = 0
  3. While intcounter < 5
  4.     reportname = Georeport(intcounter)
  5.     rst.FindFirst ("[Support File Name] LIKE 'Identity_Management_Comp_imt_overview_" & reportname & ".csv'")
  6.     LastMod = rst![Support File Modified Date]
  7.     MonName = rst![MonitorName]
  8.     ButName = rst![CommandButtonName]
  9.     If LastMod < Date Then
  10.         strFormName = Screen.ActiveForm.Name
  11.         Forms!frm_Main.Controls(MonName).BackColor = 4678655
  12.         Forms!frm_Main.Controls(ButName).Caption = "Recheck"
  13.  
  14.     Else
  15.         strFormName = Screen.ActiveForm.Name
  16.         Forms!frm_Main.Controls(MonName).BackColor = 65280
  17.         Forms!frm_Main.Controls(ButName).Caption = "Replace"
  18.  
  19.     End If
  20.     intcounter = intcounter + 1
  21. Wend
Jun 19 '12 #1

✓ answered by dsatino

Well, I think the most obvious thing to do if the form name isn't dynamic is to simply write in the form name instead of using the active form reference.

1 1895
dsatino
393 256MB
Well, I think the most obvious thing to do if the form name isn't dynamic is to simply write in the form name instead of using the active form reference.
Jun 19 '12 #2

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

Similar topics

4
by: peppeprof | last post by:
Hi- I need to use self.scrollTo(x,y) as the last action in a js function called by a onClick event. It seems that the scrolling actually takes place, but the document is then scrolling back to...
2
by: Josh Strickland | last post by:
I am attempting to create an Access database which uses forms to enter data. The issue I am having is returning the query results from the Stored Procedure back in to the Access Form. ...
5
by: MLH | last post by:
Having identified a A97 bug in which acDialog causes undesirable side effects processing the opened form, I would like to replace the following code running in MyForm ... DoCmd.OpenForm...
1
by: Default | last post by:
Hi, I am new to C#, that is why I am not sure what kind of problem it is: Is VS files corrupted , or something else. that is the problems description: I am working on a small database project. I am...
2
by: John | last post by:
Hi, I have a web form accounting app. In certain instances it causes trouble if the user clicks the Back button. I've read several posts that indicate that it is not recommended (or even...
5
by: Adrian Enders | last post by:
I have something that I have never seen before in a MS development product. I have a pretty simple call to a network directory that looks something like this ... Dim dirFolder As...
6
by: Thelma Lubkin | last post by:
I am trying to modify an Access form that allows a user to specify the information s/he needs from a census-type database. The form's code builds a SQL statement from the user's request, and...
3
by: Michael | last post by:
I work with a highly programmed Access database (some 15,000 lines of VBA code, much of it automating data entry on forms -- and believe me, it's very tight code). In Access 97, 2000, 2002, and...
12
by: bnono | last post by:
Hi all, I developed some VBA code in MS Access 2003, and during execution I print messages indicating the overall progress in a textbox of the active form (and also in the bottom status bar). To...
4
by: sphinney | last post by:
Hi everyone. I'm creating an application inside Access 2007. The application will retrieve data from various locations on my company's network servers. Depending on the time of day, alignment of...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
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...
1
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...
0
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...
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,...

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.