Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    Miki52 is offline Novice
    Windows 11 Access 2021
    Join Date
    Jan 2024
    Posts
    11

    button to open a mask that contains tab control


    Hello,
    I would like to insert in a mask a button to open a mask (MASK) that contains a tab control (CtrlSchede) and activate page 2 of the tab control


    I tried to enter the following code on click of button:

    Code:
    Private Sub Pulsante_Click()
    DoCmd.OpenForm "MASK!CtrlSchede.Value = 1".....
    End Sub
    
    but I have an error return for mask not found.


    What’s wrong with the syntax of the code?

  2. #2
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    easy enough to tell you but you'll learn more by finding resources and reviewing them
    https://learn.microsoft.com/en-us/of...docmd.openform
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    Miki52 is offline Novice
    Windows 11 Access 2021
    Join Date
    Jan 2024
    Posts
    11
    Sorry,
    I was not clear.
    I know the syntax of the cmd Open Form, but I wanted help using it in my case.
    I have initial knowledge of access...

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    You are opening a form
    Clear and simple.
    If you want to assign a value to a control when the form opens, do so in the Load event of the form.

    To select a tab control, you would set focus to it.
    https://www.google.com/search?q=setf...obile&ie=UTF-8

    Nowhere in the open form command is any option to do what you are just making up.
    It is called a language for a reason.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    Miki52 is offline Novice
    Windows 11 Access 2021
    Join Date
    Jan 2024
    Posts
    11
    Ok.
    Avevo alcuni dubbi che si potevano fare con il comando openform
    Questa operazione verrà eseguita nell'evento Load del modulo.
    Grazie

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Quote Originally Posted by Miki52 View Post
    Ok.
    Avevo alcuni dubbi che si potevano fare con il comando openform
    Questa operazione verrà eseguita nell'evento Load del modulo.
    Grazie
    Non comprende. Lo siento.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  7. #7
    Miki52 is offline Novice
    Windows 11 Access 2021
    Join Date
    Jan 2024
    Posts
    11
    Sorry,
    I have posted the untranslated version.. I am in Italy.
    Here is the correct version:
    "Ok.
    I had some doubts that the operation could be done with the openform command of a module.
    I will execute the operation with the Load event of the module to open.
    Thank you

  8. #8
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Just a note, you do not have to do it in the Load event of the form in case setting the focus to a specific page of the tab control is a "one-off" instance as I assume it would be in your case (otherwise you would simply make that the first page of the tab and no code would be required). You simply need to set the value of the tab control immediately after you opened the form by using a reference to it
    Code:
    Private Sub Pulsante_Click()
    DoCmd.OpenForm "frmYourForm".....
    Forms!frmYourForm.CtrlSchede.Value = 1 'assumes CtrlSchede is the tab control
    End Sub
    Here is a related link:
    https://www.askwoody.com/forums/topi...a-tab-control/
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  9. #9
    Miki52 is offline Novice
    Windows 11 Access 2021
    Join Date
    Jan 2024
    Posts
    11
    Quote Originally Posted by Gicu View Post
    Just a note, you do not have to do it in the Load event of the form in case setting the focus to a specific page of the tab control is a "one-off" instance as I assume it would be in your case (otherwise you would simply make that the first page of the tab and no code would be required). You simply need to set the value of the tab control immediately after you opened the form by using a reference to it
    Many thanks for the suggestion.
    Very, very useful indeed.
    I have another problem.
    In the Open Form command I would have entered a Where like this:
    Code:
    "[ID]=" & Me![ID]
    How do I put it in this context?
    If I put it in OpenForm the command does not complain because it does not indicate the right Tab of the control cards. Can you give me another suggestion?
    Sorry my English, I’m in Italy
    Thank you

  10. #10
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    You do it exactly the same, but you add the Where clause to the DoCmd.OpenForm to open the form (mask) to the desired ID then on the next line you assign the value of 1 to the tab control to show the second page (tab page indexes being 0 based).

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  11. #11
    Miki52 is offline Novice
    Windows 11 Access 2021
    Join Date
    Jan 2024
    Posts
    11
    This operation doesn’t work.
    The reference [ID] is in tab 1, which opens after the Openform command with the Where.
    The Openform command is successful, tab 1 is activated, but the condition of the [ID] is not respected.

  12. #12
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Please show us the code exactly how you have it.
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  13. #13
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Should be something like this:
    Code:
    Private Sub Pulsante_Click()
    DoCmd.OpenForm "frmYourForm", , , "ID=" & Me.ID
    Forms!frmYourForm.CtrlSchede.Value = 1 'assumes CtrlSchede is the tab control
    End Sub
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  14. #14
    Miki52 is offline Novice
    Windows 11 Access 2021
    Join Date
    Jan 2024
    Posts
    11
    Quote Originally Posted by Gicu View Post
    Should be something like this:
    Code:
    Private Sub Pulsante_Click()
    DoCmd.OpenForm "frmYourForm", , , "ID=" & Me.ID
    Forms!frmYourForm.CtrlSchede.Value = 1 'assumes CtrlSchede is the tab control
    End Sub
    That’s right, this is the code.
    The condition Where is before the activation of CtrlSchede=1
    CtrlSchede=1 does not activate with [ID] required

  15. #15
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Well if you have subforms on each tab it will not. The Where is for the Mainform?
    Likely need to issue a FindFirst of the recordsetclone for your tab control subform. Or perhaps just setfocus to the subform control if they are linked by Parent & Child.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Button to create/open or copy/open an excel file
    By petrikos in forum Programming
    Replies: 23
    Last Post: 10-15-2021, 07:00 AM
  2. Replies: 4
    Last Post: 11-24-2020, 03:41 PM
  3. Replies: 1
    Last Post: 02-14-2016, 10:18 AM
  4. Replies: 5
    Last Post: 10-13-2015, 02:53 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