Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2005
    Posts
    41

    Unanswered: Selection in a ComboBox determines Macro to Run

    I have a comboBox that is being used to determine a record to work on. I would also like this combobox to determing what Access Macro to run. The Macro is going to control what form opens up. I tried to write some simple code but this was one thing I was never good at.

    Any ideas or hints is appreciated as always!

    Code is as follows:

    Private Sub View_Record_Click()
    On Error GoTo Err_View_Record_Click

    If Me![ComboSelectProduct] = "PPO - Options PPO" Then

    Dim stDocName As String

    stDocName = "Macro - From Select to View"
    DoCmd.RunMacro stDocName

    Else
    If Me![ComboSelectProduct] = "PPO - Options PPO with Copay" Then

    stDocName = "Macro - From Select to View 2"
    DoCmd.RunMacro stDocName
    End If

    Exit_View_Record_Click:
    Exit Sub

    Err_View_Record_Click:
    MsgBox Err.Description
    Resume Exit_View_Record_Click

    End Sub

  2. #2
    Join Date
    Feb 2005
    Posts
    41

    Never Mind...

    Sorry to waste all your time I just realized that I forgot the end if at the end of the code.

    Just tested it and it works like a charm.

    Thanks again.

    Private Sub View_Record_Click()
    On Error GoTo Err_View_Record_Click

    If Me![ComboSelectProduct] = "PPO - Options PPO" Then

    Dim stDocName As String

    stDocName = "Macro - From Select to View"
    DoCmd.RunMacro stDocName

    Else
    If Me![ComboSelectProduct] = "PPO - Options PPO with Copay" Then

    stDocName = "Macro - From Select to View 2"
    DoCmd.RunMacro stDocName
    End If
    end if

    Exit_View_Record_Click:
    Exit Sub

    Err_View_Record_Click:
    MsgBox Err.Description
    Resume Exit_View_Record_Click

    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •