Results 1 to 6 of 6
  1. #1
    michi is offline Novice
    Windows 10 Office 365
    Join Date
    Nov 2021
    Posts
    2

    Question DoCmd.setProperty

    Hello all
    I am a newcomer to VBA. I am trying to open a form "frmAuftragUebersicht" from the form "frmStart" via a command button. In the new form the field "cboKunde" should get inactive. It still does not work after hours. Please help me.


    Private Sub cmdAuftragAusgefuehrt_Click()
    '------------------------
    'Das Formular frmAuftragUebersicht öffnen
    'und den Fokus in das Feld cboAuftragsnummerSuchen setzen
    'das Feld "cboKunde" soll inaktiviert werden
    '------------------------
    DoCmd.OpenForm "frmAuftragUebersicht", acNormal
    DoCmd.GoToControl "cboAuftragsnummerSuchen"
    DoCmd.SetProperty "cboKunde", acPropertyEnabled, "0"




    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Try

    Forms!frmAuftragUebersicht.cboKunde.Enabled = False
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    To clarify, your code becomes:

    DoCmd.OpenForm "frmAuftragUebersicht", acNormal
    Forms!frmAuftragUebersicht.cboKunde.Enabled = False
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,798
    You cannot use that syntax in the code of the same form that you're using to open form B. You must use

    Forms!myFormNameHere.theControlNameHere.Enabled = false

    However, if you're going to do this regardless, as you have shown, why not just set that property in form design and be done with it? Are you setting focus (going to) some control because cboKunde has the focus when you open the form? If so, could just either remove it from the tab order or set the tab index to something other than zero.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    michi is offline Novice
    Windows 10 Office 365
    Join Date
    Nov 2021
    Posts
    2
    Thank you very much for the tips. I use the frmAuftragUebersicht form in three different phases. 1. to enter a new order. 2. to complete the work on the order. And thirdly, when the customer picks up the order. So I want to make fields inactive that should no longer be changed.

    The code 'Forms!frmAuftragUebersicht.cboKunde.Enabled = False' does work.

  6. #6
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,409
    You can use the OpenForm OpenArgs to pass "instructions" when opening one form from another. This is handy when the target form is opened from several other forms and the target needs to know how it is expected to react. The target uses the Form_Open event to analyze the OpenArgs value to take appropriate actions, like disabling a control.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. SetProperty for OnFormat in Report
    By Nico80000 in forum Macros
    Replies: 5
    Last Post: 04-29-2021, 01:24 PM
  2. Replies: 2
    Last Post: 09-27-2016, 09:10 PM
  3. Replies: 4
    Last Post: 10-08-2013, 02:42 AM
  4. Replies: 2
    Last Post: 09-13-2012, 12:25 PM
  5. Correct way to SetProperty with Macro Builder
    By jasonbarnes in forum Forms
    Replies: 4
    Last Post: 02-25-2011, 02:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums