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

How do you open a form, and Automagically click a button?

anoble1
245 128KB
Hi,

I am running into an issue with a MS Access form. When I open my form I have a lot of text boxes that will update once a button on the form is pressed. (takes about 30 seconds to run through code and update), but I want to do Away with the button, and make it to when you open the form it automatically clicks that "hidden" button and populates data.

I have not been able to make it work for some reason. So, how do you click a button when you tell the form to load? Is their a special spot?

Thanks,
Jan 6 '12 #1
5 4142
Rabbit
12,516 Expert Mod 8TB
You don't have to. The button click does only one thing, trigger the function linked to the button click. You can forego the button click and just copy the code into the OnLoad event of the form.
Jan 6 '12 #2
Seth Schrock
2,965 Expert 2GB
Just move the code from the OnClick event on the button to the OnLoad event of the form. You can then delete the button instead of just hidding it. If the button is supposed to run a macro, you can put that macro into the OnLoad event.
Jan 6 '12 #3
Mihail
759 512MB
Or, from the OnLoad event, apply the routine for yours button click event.
Expand|Select|Wrap|Line Numbers
  1. Call YourButtonName_Click
Jan 7 '12 #4
Brian Connelly
103 100+
I agree with Seth. You may not want to remove the button for future use. I would call the button method from th OnLoad event, although Rabbit is correct by placing the code in the OnLoad. Either way should do the trick.
Jan 7 '12 #5
NeoPa
32,556 Expert Mod 16PB
I generally advise where a situation occurs that requires the same code to be run from more than one event, that a separate procedure is designed to handle the common code rather than either of the event procedures be called from the other.

IE. :
Expand|Select|Wrap|Line Numbers
  1. Private Sub {EventA}()
  2.     Call {CommonSub}()
  3. End Sub
  4.  
  5. Private Sub {EventB}()
  6.     Call {CommonSub}()
  7. End Sub
  8.  
  9. Private Sub {CommonSub}()
  10.     ' Common code
  11. End Sub
As opposed to :
Expand|Select|Wrap|Line Numbers
  1. Private Sub {EventA}()
  2.     Call {EventB}()
  3. End Sub
  4.  
  5. Private Sub {EventB}()
  6.     ' Common code
  7. End Sub
If you later need to maintain this code you will be glad you managed it the former way ;-)
Jan 8 '12 #6

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

Similar topics

3
by: BLUE WATER | last post by:
Hi, I have managed to simplify my problem but can't seem to get this to work. I want to open up a form from a click event of another form, but not only open the form when the button is pressed...
5
by: Steve | last post by:
Hi, Is it possible to make hitting the enter key in an ASP textbox run the code behind an ASP button on a form? I have a search page which users tend to type in the query then just hit enter...
1
by: JAG711 | last post by:
How can I open a MDI childform from it's parent form and then programmically run an event or procedure from the childform. ie. run the click event code of the child form's command button.
2
by: erick-flores | last post by:
Hello all Form A (pk) & Form B (fk) I want to display my Form B empty whenever is the first time, that the pk form Form A, is enter. I click a button to open Form B. BUT if the pk from Form A...
3
by: smay | last post by:
I'm writing an app that is launched by right-clicking on an XML file and choosing Open With - My App. My App launches another 3rd-party desktop app to import the XML file into. However, before...
14
by: keri | last post by:
Hi, Simple version of the question..... How do I use the where clause of the open form command to show an account with a matching ID to be displayed when the form is opened? Eg. I select a...
12
by: djmauro | last post by:
as title says. I cant find a way to do this. if i use form1.show and click on a button. it opens that form, but as soon as i click again it just reopens it and closes previously opened form. So is...
3
by: vidhyapriya | last post by:
Hi all I am developing windows application using vb.net.I want to pass values to open form.I am opening only one form when user click the buttons several times.Useing delegate i am passing...
0
by: vidhyapriya | last post by:
Hi all, I am using two forms.From form1 button click i am opening form2,and i am passing values to form2 using delegate.when i click the button again form2 shouldn't open again but values...
5
by: billa856 | last post by:
Hi, My project is in MS Access 2002. In that I want to open one form multiple times. I put one button on my main form. Now whenever I click on that button than form will be open. Now when I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...

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.