Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2003
    Location
    UK
    Posts
    85

    Question Unanswered: Option group and combo box problem

    Dear All

    I did put the same question earlier on but that wasn't fully elaborated. That is whay I have put it again to make my question clear.

    I want to filter the records using two parameters.

    I want one parameter to be selected from a combobox and the second one from an option groups. So the structure would be somewhat similar to as follows

    Cumbo box = Customer

    Option group
    Option1
    Option2
    Option3

    Combo box1 = linked to Option1
    Combo box2 = linked to Option2
    Combo box3= linked to Option3

    Command button = Open report


    Now what I want is,

    I select a customer from combo box and select one of the three options and click on Open report button to view the report (based on a query) which should be filtered by Customer and Option1 (PART NO) field and so on.

    I have managed to develop some code but there is something I am doing wrong because the report does open if I run the code individually e.g either only for customer or only for Option1(PART NO), but not when I put both in the code.

    Sub viewresults(PrintMode As Integer)

    Dim myInt As String
    Dim myInd As String

    myInd = CmbCustomer

    Select Case Me!frame2
    Case 1
    myInt = Forms![F_rqform]!CmbOption1

    DoCmd.OpenReport "Report3", acViewPreview, , "[CUSTOMER] = '" & myInd & "'" And "[PART NO] = '" & myInt & "'"

    Case 2
    myInt = Forms![F_rqform]!CmbOption2
    DoCmd.OpenReport "Report3", acViewPreview, , "[CUSTOMER] = '" & myInd & "'" And "[REF NO] = '" & myInt & "'"

    Just a reminder that I am at the very early stages of learning VB codes, so I might have made a major mistake.

    Looking forward to your reply

  2. #2
    Join Date
    Nov 2002
    Location
    Belgium
    Posts
    243

    Re: Option group and combo box problem

    Originally posted by dbase
    Dear All

    I did put the same question earlier on but that wasn't fully elaborated. That is whay I have put it again to make my question clear.

    I want to filter the records using two parameters.

    I want one parameter to be selected from a combobox and the second one from an option groups. So the structure would be somewhat similar to as follows

    Cumbo box = Customer

    Option group
    Option1
    Option2
    Option3

    Combo box1 = linked to Option1
    Combo box2 = linked to Option2
    Combo box3= linked to Option3

    Command button = Open report


    Now what I want is,

    I select a customer from combo box and select one of the three options and click on Open report button to view the report (based on a query) which should be filtered by Customer and Option1 (PART NO) field and so on.

    I have managed to develop some code but there is something I am doing wrong because the report does open if I run the code individually e.g either only for customer or only for Option1(PART NO), but not when I put both in the code.

    Sub viewresults(PrintMode As Integer)

    Dim myInt As String
    Dim myInd As String

    myInd = CmbCustomer

    Select Case Me!frame2
    Case 1
    myInt = Forms![F_rqform]!CmbOption1

    DoCmd.OpenReport "Report3", acViewPreview, , "[CUSTOMER] = '" & myInd & "'" And "[PART NO] = '" & myInt & "'"

    Case 2
    myInt = Forms![F_rqform]!CmbOption2
    DoCmd.OpenReport "Report3", acViewPreview, , "[CUSTOMER] = '" & myInd & "'" And "[REF NO] = '" & myInt & "'"

    Just a reminder that I am at the very early stages of learning VB codes, so I might have made a major mistake.

    Looking forward to your reply
    You wrote : "[CUSTOMER] = '" & myInd & "'" And "[PART NO] = '" & myInt & "'"

    but try this :
    "[CUSTOMER] = '" & myInd & "' And [PART NO] = '" & myint & "'"


    ! Look as the quotes !

  3. #3
    Join Date
    Mar 2003
    Location
    UK
    Posts
    85
    artemide

    Thank you very much for your reply.

    Some other nice guy has also just suggested the same thing. I have tried it and it worked fine.

    Thank you very much for you help.

    Regards

Posting Permissions

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