click button when form opens/loads?

smile

Registered User.
Local time
Today, 11:08
Joined
Apr 21, 2006
Messages
212
Hi, I have a form and made my custom buttons to enter =date() into textbox1 that is used in query criteria and would like to auto click it when form opens.

My button name is: frm_laikotarpis_current

I have to put this on form open even:

DoCmd.RunCommand frm_laikotarpis_current_Click()

but it gives me error: expected function or variable.

Also I have a 2nd problem

I have a unbound textbox2 that shows query result on same form. When I click my button manually (that sets date on unbound textbox1) the unbound textbox2 fields are not updated. I tried to add refresh button and get error: the command or action refresh isn't available now.

Tried to put my "calculated fields" on subform with refresh button and include it to main form - same error. I think it is because when you click refresh button it would clear the textbox that holds information for criteria.

Is it possible to reload refresh a subform by a button on main form, I think it would work?
 
Last edited:
DoCmd.RunCommand frm_laikotarpis_current_Click()

but it gives me error: expected function or variable.
It's a subroutine so you use CALL to run it. Try:
Call frm_laikotarpis_current_Click

I have a unbound textbox2 that shows query result on same form. When I click my button manually (that sets date on unbound textbox1) the unbound textbox2 fields are not updated. I tried to add refresh button and get error: the command or action refresh isn't available now.
How are you getting information into textbox2 to start with?

Chris
 
You sollution works perfect the button auto clicked. Thanks.

About my 2nd problem.

"How are you getting information into textbox2 to start with?"

I have a query that pulls the data, then I had a code in the textbox2 to display the data

=Nz(DLookUp("my_field_name";"my_qry_name";"my_field_name"="my_field_name");0)

BTW I did not want to use dlookup as it's slow but is there better way?

It worked fine as long as I had the code in my texbox1:

=Date()

The form opens and both texfields show data.
-------------------------------------------------------------

Now when I populate the textbox1 with a button I have VBA code to fill the textbox1 with =Date()

And I can enter my custom date via date picker.
The problem is that form opens with blank textbox1 and textbox2 is blank too.

I have fixed the blank textbox 1 and 2 problem with your code that auto click the button but if I enter custom date I cant update textbox2. I get error: the command or action refresh isn't available now.

So is there some code that I could place on custom refresh button that will make textbox2 requery (pull updated) the information again?
 
Last edited:

Users who are viewing this thread

Back
Top Bottom