Results 1 to 5 of 5
  1. #1
    tmcrouse is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Apr 2009
    Posts
    169

    command button not right

    I have several listboxes and comboboxes. These allow the end-user to select what they want to see. Then I have a command button that looks at what they selected and then pulls that information from the query that feeds the command button. When I click my command button it does not do anything. Here is my code:

    Code:
    Private Sub Command8_Enter()
    Dim WhereString As String
    Dim QueryName As String
    Dim myvar As String
    Dim myvar2 As String
    Dim myvar3 As String
    Dim myvar4 As String
    Dim myvar5 As String
    Dim myvar6 As String
    Dim myvar7 As String
    Dim myvar8 As String
    Dim myvar9 As String
    Dim myvar10 As String
    myvar = Me.List1.Column(0)
    myvar2 = Me.List2.Column(0)
    myvar3 = Me.List3.Column(0)
    myvar4 = Me.List4.Column(0)
    myvar5 = Me.List5.Column(0)
    myvar6 = Me.Combo1.Column(0)
    myvar7 = Me.Combo2.Column(0)
    myvar8 = Me.Combo3.Column(0)
    myvar9 = Me.combo4.Column(0)
    myvar10 = Me.List6.Column(0)
    Debug.Print myvar
    Debug.Print myvar2
    Debug.Print myvar3
    Debug.Print myvar4
    Debug.Print myvar5
    Debug.Print myvar6
    Debug.Print myvar7
    Debug.Print myvar8
    Debug.Print myvar9
    Debug.Print myvar10
    If IsNull(Me.List1) Or IsNull(Me.List2) Or IsNull(Me.List3) Or IsNull(Me.List4) Or IsNull(Me.List5) Or IsNull(Me.Combo1) Or IsNull(Me.Combo2) Or IsNull(Me.Combo3) Or IsNull(Me.combo4) Or IsNull(Me.List6) = False Then
    QueryName = "QUALQ1"
    WhereString = " OpCo = " & myvar & myvar2 & myvar3 & myvar4 & myvar5 & myvar6 & myvar7 & myvar8 & myvar9 & myvar10
    Debug.Print WhereString
    DoCmd.OpenReport ReportName, acViewReport, , WhereString
    End If
    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,640
    Well for starters you have the code in the enter event rather than the click event. Is any code running in the db? It has to be in a trusted location or you have to explicitly enable code to run.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    There is a QueryName = "QUALQ1" defined. However

    --> DoCmd.OpenReport ReportName, acViewReport, , WhereString

    but the "ReportName" is no where to be found (unless it is a public global variable).

  4. #4
    tmcrouse is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Apr 2009
    Posts
    169
    Thanks. Ok, I changed it to a click event and also change it to

    DoCmd.OpenQuery QualQ1, acViewNormal, acReadOnly, WhereString

    I have no code running in the db. I just have my form with the textboxes and comboboxes and the user select what they want and based on that when clicking the command button I want it to look for that information and apply it to the query. The query looks for everything. It is based on pulling in everything from the tables I have built and what they are doing with textboxes and comboxes is limiting the return. For example 1 table is st_cd and it lists all states 2 letter code. So my query chooses all states. But the combobox set up for that has all the state 2 letter codes and they can choose 1, 2, 40, whatever. If they say choose only NY, then when they click the button, it will return NY information from that query I built. The query is not specific to NY. It is everything. So, I am a little confused if I am even coding this correctly.

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,601
    Code is to build filter criteria.

    Why do you concatenate variables? What type of data is in OpCo field?
    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.

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

Similar Threads

  1. Replies: 3
    Last Post: 08-04-2013, 07:11 AM
  2. Command button
    By jiawen in forum Access
    Replies: 3
    Last Post: 01-12-2013, 12:07 PM
  3. Button Command
    By JayX in forum Access
    Replies: 7
    Last Post: 12-27-2011, 12:58 PM
  4. Replies: 1
    Last Post: 07-27-2010, 02:27 PM
  5. Command Button
    By lannoe in forum Forms
    Replies: 1
    Last Post: 07-01-2010, 01:48 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