By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,985 Members | 1,861 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,985 IT Pros & Developers. It's quick & easy.

If statement for an Open Event if button click

P: n/a
Hello

When my form opens I want to check IF the form was open clicking
Button#1 then do something else do something endif

Something like:

Private Sub Form_Open(Cancel As Integer)
If this-form-was-open-withButton#1 then
do something
else
do something
endif
end sub

Thanks

Aug 17 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
If Me.OpenArgs = "Button#1" then
....
else
---
end if

Check OpenArgs in the Help

Arno R

"erick-flores" <ch**********@hotmail.comschreef in bericht news:11**********************@m73g2000cwd.googlegr oups.com...
Hello

When my form opens I want to check IF the form was open clicking
Button#1 then do something else do something endif

Something like:

Private Sub Form_Open(Cancel As Integer)
If this-form-was-open-withButton#1 then
do something
else
do something
endif
end sub

Thanks
Aug 17 '06 #2

P: n/a

Arno R wrote:
If Me.OpenArgs = "Button#1" then
...
else
---
end if
What if the button is on other form? the "Me." wont work
Let say the name of the form is MAINMENU

I tried:
If Forms![MAINMENU].OpenArgs = "button#1" then

and its not working....any ideas???

Aug 17 '06 #3

P: n/a

Or maybe there is an easy way to do it. Basically I just want to set
the nvigationsbutton=false is a button is press and =true if the other
is press.
I tried to put the code behind the actual button, but it didnt
work...is it possible to do this?

I did:
Private Sub open_currentuser_Click()

Dim stDocName As String

stDocName = "Expense Reports by Employee"
DoCmd.OpenForm stDocName
stDocName.NavigationButtons = False

End Sub

But it didnt work...it didnt even allow me to open the form

Aug 17 '06 #4

P: n/a
erick-flores wrote:
Or maybe there is an easy way to do it. Basically I just want to set
the nvigationsbutton=false is a button is press and =true if the other
is press.
I tried to put the code behind the actual button, but it didnt
work...is it possible to do this?

I did:
Private Sub open_currentuser_Click()

Dim stDocName As String

stDocName = "Expense Reports by Employee"
DoCmd.OpenForm stDocName
stDocName.NavigationButtons = False

End Sub

But it didnt work...it didnt even allow me to open the form
stDocName is not a form. It is a string that is the name of a form.

Forms(stDocName).NavigationButtons = False

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Aug 17 '06 #5

P: n/a

It worked, thank you very much

Aug 17 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.