Results 1 to 7 of 7
  1. #1
    balajigade is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Mar 2014
    Posts
    30

    Embedded Macro

    A newbie to Access 2007. Trying to pass parameters to a query alternatively from two combo boxes on a form : Combo0 & combo2 which provide the id no. & student name from look up tables respectively. Two option buttons facilitate the selection between the two combo boxes so that when one combo box is enabled, the other is disabled. A command button is there on the forum to make the query run. Without closing the form, I want that whenever I select one option (of entering the id no. or the student name) the other combo box should be reset to null. Suggest steps for embedding the code in the macro builder.



    Thanks
    Last edited by balajigade; 03-05-2014 at 09:42 AM.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    I don't use macros, only VBA. This would be so easy in VBA.

    I think this has to be done with SetValue method in macro.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    balajigade is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Mar 2014
    Posts
    30
    Can you suggest the code. Not able to reset even after setting null value or " " in the default option of the combobox, unless I quit from the form and reopen it.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    These are unbound comboboxes used to input filter criteria?

    The option buttons are radio buttons in an option group?

    Set both comboboxes as disabled then user must click radio button to enable one?

    Code behind option group AfterUpdate event, something like:

    Me.combo1 = Null
    Me.combo2 = Null
    Me.combo1.Enabled = Me.option = 0
    Me.combo2.Enabled = Me.option = 1
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    balajigade is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Mar 2014
    Posts
    30
    Thanks. The combo boxes are bound to look up tables. I would like the command button to stay disabled unless at least one of the combo boxes is not null.This will prevent generating blank reports

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    The comboboxes have RowSource that reference table, they are not 'bound' to the table. Binding a control means setting ControlSource property.

    Use code in each combobox AfterUpdate event.

    Me.commandbutton.Enabled = Not IsNull(Me.combobox1) Or Not IsNull(Me.combox2)
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    balajigade is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Mar 2014
    Posts
    30
    Thanks Problem solved

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

Similar Threads

  1. Replies: 2
    Last Post: 06-30-2013, 09:59 AM
  2. Embedded Macro not there
    By notacluewhatimdoing in forum Forms
    Replies: 4
    Last Post: 03-23-2013, 08:04 AM
  3. Embedded Macro
    By sireesha in forum Forms
    Replies: 1
    Last Post: 12-08-2012, 02:28 PM
  4. Embedded macro
    By thart21 in forum Forms
    Replies: 1
    Last Post: 06-28-2011, 12:18 PM
  5. Run Embedded Macro
    By smikkelsen in forum Forms
    Replies: 0
    Last Post: 07-07-2010, 09:44 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