Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 24th, 2004, 06:37 PM
Authorized User
 
Join Date: Nov 2003
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to bjackman Send a message via MSN to bjackman
Default Controls on another form

I have a form with a command button and when i click it, it opens another form to selct criteria for a report. what i'm trying to do is when i click button 1 to open the other form, i want to be able to disable certain controls depending on which command button was clicked on form 1. Is this possible?? Any help would be greatly appreciated.

Branden

 
Old March 24th, 2004, 11:14 PM
Authorized User
 
Join Date: Jun 2003
Posts: 54
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Try putting some string like "condition_1" in the TAG property of the controls you want to have enabled when "condition 1" occurs (e.g. you click on a certain button in form 1 occurs). Use "condition_2" for some other type action.

Use the Open_Args parameter of the DoCmd.OpenForm to pass the string "condition_1" to the other form.

In form 1's OPEN event, read the Me.OpenArgs property. Then try something like this:

---------------------------------------------------
For Each ctl in Me.Controls

    If ctl.Tag = Me.OpenArgs then
        ctl.Enable = True
    Else
        ctl.Enable = False
    End If


Next ctl
--------------------------------------------------

You may have to "tweak" this but it has worked well
for me in the past.

Cheers!



--- Tom
 
Old March 25th, 2004, 01:30 AM
Authorized User
 
Join Date: Nov 2003
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to bjackman Send a message via MSN to bjackman
Default

I appreciate your reply but i actually figured it out. i used the following code

Private Sub cmdShiftReport_Click()
On Error GoTo Err_cmdShiftReport_Click

    Dim frmname As String
    frmname = "frmDetailReport"

        DoCmd.OpenForm frmname

            Forms.frmdetailreport.startdate.SetFocus
            Forms.frmdetailreport.EmployeeName.Enabled = False
            Forms.frmdetailreport.cmdStateDetail.Enabled = False

Exit_cmdShiftReport_Click:
    Exit Sub

Err_cmdShiftReport_Click:
    MsgBox Err.Description
    Resume Exit_cmdShiftReport_Click

End Sub

If this would help you out as it seems to be a little easier, feel free.

Branden






Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding controls to a form Scootterp Access VBA 2 August 4th, 2009 02:32 PM
1 form, contains two seperate controls EricJ General .NET 2 August 10th, 2005 04:48 AM
Search Controls on a Form donnie_darko1983 ASP.NET 1.0 and 1.1 Basics 2 April 12th, 2005 05:20 AM
listing controls of form melvik C# 1 April 22nd, 2004 06:00 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.