• Conditional ‘Show’ (2000 sp3)

    Author
    Topic
    #404109

    I have a table which records receipts. A particular rider may pay by cash, cheque, credit card or money order. They may also pay by any combination of these and may pay with a cheque or credit card from someone else. I have the default details of their preferred payment method stored and automatically displayed as a suggested entry when they pay. However, I have this showing ALL the time ie if they pay by cash this time but their default is to pay by cheque, the form will display their bank details. I would like the choosing of the payment method (cash cheque etc) to automatically show only the appropriate details for that payment method eg if they choose cheque, show the bank details but not the credit card details stored in their master file; if by credit card, hide the bank details; by cash, hide all – any suggestions
    TIA
    Steve

    Viewing 1 reply thread
    Author
    Replies
    • #819670

      I would put a select case statement in the after-update event of the payment method control, that shows or hides the approrpiate controls , by setting their visible property to true or false.

      I would also put the same code in the oncurrent event, so that the same thing happens when you look back at old data.

      E.g

      Select Case me![PaymentMethod]

      Case: “Cash”
      me![BSB].visible = false

      etc

      Post back if want more help in writing out the code

      • #819686

        Thanks for the suggestion (I think I did the code right but I am very inexperienced in code). One problem that I didn’t explain fully, is that I have the bank account details etc in the master file and these are automatically being entered into the receipt as the default via the .[forms] technique. This technique is great and saves heaps of time/reduces data entry errors when the guy picks his default method of payment. I really need to blank the data for the BSB etc for when a guy who normally pays by cheque and who has his banking details in the master file, decides to pay by another method. When I tried your suggestion (assuming I didnt screw up the code), it changed nothing – understandable given my default values settings
        Thanks very much for the quick response
        Steve
        PS I would be interested in an example of the full code as the technique would be really useful elsewhere and to see if I screwed up

      • #819687

        Thanks for the suggestion (I think I did the code right but I am very inexperienced in code). One problem that I didn’t explain fully, is that I have the bank account details etc in the master file and these are automatically being entered into the receipt as the default via the .[forms] technique. This technique is great and saves heaps of time/reduces data entry errors when the guy picks his default method of payment. I really need to blank the data for the BSB etc for when a guy who normally pays by cheque and who has his banking details in the master file, decides to pay by another method. When I tried your suggestion (assuming I didnt screw up the code), it changed nothing – understandable given my default values settings
        Thanks very much for the quick response
        Steve
        PS I would be interested in an example of the full code as the technique would be really useful elsewhere and to see if I screwed up

      • #819688

        Just a later thought- I dont really mind if the data ends up being a bit duplicative (eg has details of both bank account and credit card account even though payt was by credit card this time). Its really just at report stage that it looks messy with cash payments showing a default bank account etc.
        Is there an equivalent case approach where I only show fields in the report based on the selection of the payment method
        Steve

        • #819718

          You can put code in the On Format event of the section of the report that contains the payment method and bank account details. For example, if they are on the Detail section. The following is air code, the details depend on your setup. If you would like detailed assistance, you will need to tell us more about the names and types of the fields involved.

          Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
          Select Case Me.[PaymentMethod]
          Case “Cash”
          Me.[BankAccountNumber].Visible = False
          Me.[CreditCardNumber].Visible = False
          Case “Bank”
          Me.[BankAccountNumber].Visible = True
          Me.[CreditCardNumber].Visible = False
          Case “CreditCard”
          Me.[BankAccountNumber].Visible = False
          Me.[CreditCardNumber].Visible = True
          End Select
          End Sub

        • #819719

          You can put code in the On Format event of the section of the report that contains the payment method and bank account details. For example, if they are on the Detail section. The following is air code, the details depend on your setup. If you would like detailed assistance, you will need to tell us more about the names and types of the fields involved.

          Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
          Select Case Me.[PaymentMethod]
          Case “Cash”
          Me.[BankAccountNumber].Visible = False
          Me.[CreditCardNumber].Visible = False
          Case “Bank”
          Me.[BankAccountNumber].Visible = True
          Me.[CreditCardNumber].Visible = False
          Case “CreditCard”
          Me.[BankAccountNumber].Visible = False
          Me.[CreditCardNumber].Visible = True
          End Select
          End Sub

        • #819766

          It might be a good idea to clear out data you are not using.

          Otherwise you need to be very careful later if you try to pull out and summary data based on the info entered.

          Whenever you hide something, all you need to do is set its value to Null

          me![BSB].visible =false
          me![BSB] = Null

          • #820026

            Wonderful – thank you both very very much – 1 problem and 1 question
            The receipts section of the form (BTW the receipts form is a subform to the Costing form) is continuous to allow for split receipts ie payment of a total of $120 via $100 cash and $20 credit card (or any other permutation). When I set the visible properties to false, if I choose say cash, it hides the bank and credit card details beautifully. However it hides it for all the continuous forms so I cannot enter , for example, a cheque payment after a cash payment as the fields are no longer visible. This is the case even if I change the original payment method from, say, cash back to cheque. I can live with the null process if necessary (its much much better than I had) but wondered if there is any solution to the problem above
            Question (may be a dumb one). I noticed in Hans’ answer to the code he used Me.[FieldName] but John (if I may be so forward as to use first names) used Me![Fieldname]. As I had already typed the code last night using John’s method, I stuck to that (and it worked). My question is whats the difference between Me. and Me! and when should I use which one
            Thanks again
            Steve

            • #820034

              In a continuous form (my code was meant for a report), there is only one set of controls. If you make a text box invisible, it becomes invisible for all records. You might use conditional formatting instead, since that will work record-by-record.

              Strictly speaking, Me![FieldName] refers to a control named FieldName, and Me.[FieldName] to a property of the form named FieldName. In most cases, they are interchangeable.

            • #820040

              Hans thanks for the clarification. My plan is to use the Null process for the receipts form and try the visible process for the resultant report. However have hit a snag
              My code is in the On format section of the detail of the report
              Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
              Select Case Me.[PaymentMethod]
              Case “Cash”
              Me.[BankBSB].Visible = False
              Me.[BankName].Visible = False
              Me.[BankBranch].Visible = False
              Me.[BankAcctNo].Visible = False
              Me.[BankAccountName].Visible = False
              Me.[CreditCardType].Visible = False
              Me.[CreditCardName].Visible = False
              Me.[CreditcardNo].Visible = False
              Me.[ExpiryDate].Visible = False
              Case “Cheque”
              Me.[CreditCardType].Visible = False
              Me.[CreditCardName].Visible = False
              Me.[CreditcardNo].Visible = False
              Me.[ExpiryDate].Visible = False
              Case “Credit Card”
              Me.[BankBSB].Visible = False
              Me.[BankName].Visible = False
              Me.[BankBranch].Visible = False
              Me.[BankAcctNo].Visible = False
              Me.[BankAccountName].Visible = False
              Case “Money Order”
              Me.[BankBSB].Visible = False
              Me.[BankName].Visible = False
              Me.[BankBranch].Visible = False
              Me.[BankAcctNo].Visible = False
              Me.[BankAccountName].Visible = False
              Me.[CreditCardType].Visible = False
              Me.[CreditCardName].Visible = False
              Me.[CreditcardNo].Visible = False
              Me.[ExpiryDate].Visible = False
              Case “Direct Deposit”
              Me.[CreditCardType].Visible = False
              Me.[CreditCardName].Visible = False
              Me.[CreditcardNo].Visible = False
              Me.[ExpiryDate].Visible = False

              End Select
              End Sub

              However when I run the report, I get Run-Time Error 2427 You Entered an Expression that has no value
              debug takes me to “Select Case Me.[PAymentMethod}
              Help

            • #820046

              Do you have a control named PaymentMethod in the detail section of the report? If not, you should put one there; it may be hidden (Visible = No) if you don’t want the user to see it.

              Or can PaymentMethod be empty for some records?

            • #820047

              Do you have a control named PaymentMethod in the detail section of the report? If not, you should put one there; it may be hidden (Visible = No) if you don’t want the user to see it.

              Or can PaymentMethod be empty for some records?

            • #820041

              Hans thanks for the clarification. My plan is to use the Null process for the receipts form and try the visible process for the resultant report. However have hit a snag
              My code is in the On format section of the detail of the report
              Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
              Select Case Me.[PaymentMethod]
              Case “Cash”
              Me.[BankBSB].Visible = False
              Me.[BankName].Visible = False
              Me.[BankBranch].Visible = False
              Me.[BankAcctNo].Visible = False
              Me.[BankAccountName].Visible = False
              Me.[CreditCardType].Visible = False
              Me.[CreditCardName].Visible = False
              Me.[CreditcardNo].Visible = False
              Me.[ExpiryDate].Visible = False
              Case “Cheque”
              Me.[CreditCardType].Visible = False
              Me.[CreditCardName].Visible = False
              Me.[CreditcardNo].Visible = False
              Me.[ExpiryDate].Visible = False
              Case “Credit Card”
              Me.[BankBSB].Visible = False
              Me.[BankName].Visible = False
              Me.[BankBranch].Visible = False
              Me.[BankAcctNo].Visible = False
              Me.[BankAccountName].Visible = False
              Case “Money Order”
              Me.[BankBSB].Visible = False
              Me.[BankName].Visible = False
              Me.[BankBranch].Visible = False
              Me.[BankAcctNo].Visible = False
              Me.[BankAccountName].Visible = False
              Me.[CreditCardType].Visible = False
              Me.[CreditCardName].Visible = False
              Me.[CreditcardNo].Visible = False
              Me.[ExpiryDate].Visible = False
              Case “Direct Deposit”
              Me.[CreditCardType].Visible = False
              Me.[CreditCardName].Visible = False
              Me.[CreditcardNo].Visible = False
              Me.[ExpiryDate].Visible = False

              End Select
              End Sub

              However when I run the report, I get Run-Time Error 2427 You Entered an Expression that has no value
              debug takes me to “Select Case Me.[PAymentMethod}
              Help

            • #820035

              In a continuous form (my code was meant for a report), there is only one set of controls. If you make a text box invisible, it becomes invisible for all records. You might use conditional formatting instead, since that will work record-by-record.

              Strictly speaking, Me![FieldName] refers to a control named FieldName, and Me.[FieldName] to a property of the form named FieldName. In most cases, they are interchangeable.

          • #820027

            Wonderful – thank you both very very much – 1 problem and 1 question
            The receipts section of the form (BTW the receipts form is a subform to the Costing form) is continuous to allow for split receipts ie payment of a total of $120 via $100 cash and $20 credit card (or any other permutation). When I set the visible properties to false, if I choose say cash, it hides the bank and credit card details beautifully. However it hides it for all the continuous forms so I cannot enter , for example, a cheque payment after a cash payment as the fields are no longer visible. This is the case even if I change the original payment method from, say, cash back to cheque. I can live with the null process if necessary (its much much better than I had) but wondered if there is any solution to the problem above
            Question (may be a dumb one). I noticed in Hans’ answer to the code he used Me.[FieldName] but John (if I may be so forward as to use first names) used Me![Fieldname]. As I had already typed the code last night using John’s method, I stuck to that (and it worked). My question is whats the difference between Me. and Me! and when should I use which one
            Thanks again
            Steve

        • #819767

          It might be a good idea to clear out data you are not using.

          Otherwise you need to be very careful later if you try to pull out and summary data based on the info entered.

          Whenever you hide something, all you need to do is set its value to Null

          me![BSB].visible =false
          me![BSB] = Null

      • #819689

        Just a later thought- I dont really mind if the data ends up being a bit duplicative (eg has details of both bank account and credit card account even though payt was by credit card this time). Its really just at report stage that it looks messy with cash payments showing a default bank account etc.
        Is there an equivalent case approach where I only show fields in the report based on the selection of the payment method
        Steve

    • #819671

      I would put a select case statement in the after-update event of the payment method control, that shows or hides the approrpiate controls , by setting their visible property to true or false.

      I would also put the same code in the oncurrent event, so that the same thing happens when you look back at old data.

      E.g

      Select Case me![PaymentMethod]

      Case: “Cash”
      me![BSB].visible = false

      etc

      Post back if want more help in writing out the code

    Viewing 1 reply thread
    Reply To: Conditional ‘Show’ (2000 sp3)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: