Using If statement between 2 text boxes in VB6

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hariharanmca
    Top Contributor
    • Dec 2006
    • 1977

    #16
    Originally posted by Wernerh
    I have used the code like you have suggested, but still same object required error. :-<<

    can you say which line is that object error?

    Comment

    • Wernerh
      New Member
      • Jul 2007
      • 104

      #17
      Originally posted by hariharanmca
      can you say which line is that object error?
      Highlights the first line : If Val(textbox4.Te xt) < 100 Then

      Comment

      • hariharanmca
        Top Contributor
        • Dec 2006
        • 1977

        #18
        Originally posted by Wernerh
        Highlights the first line : If Val(textbox4.Te xt) < 100 Then
        just check the textbox name is 'textbox4'

        Comment

        • Wernerh
          New Member
          • Jul 2007
          • 104

          #19
          Originally posted by hariharanmca
          just check the textbox name is 'textbox4'

          Damn that was wrong it is actually text4 not textbox4, but still same error! I am not sure if I should preceed that part of the code with maybe something like :

          Dim text4 as Integer ???? - tried it,but then said invalid qualifier.

          Comment

          • hariharanmca
            Top Contributor
            • Dec 2006
            • 1977

            #20
            Originally posted by Wernerh
            Damn that was wrong it is actually text4 not textbox4, but still same error! I am not sure if I should preceed that part of the code with maybe something like :

            Dim text4 as Integer ???? - tried it,but then said invalid qualifier.
            Already text4 is an textbox control then how can you declare it again for integer?

            Comment

            • Wernerh
              New Member
              • Jul 2007
              • 104

              #21
              Originally posted by hariharanmca
              Already text4 is an textbox control then how can you declare it again for integer?

              Pure shot in the dark! I am as you can see a TOTAL newbie at this, so just starting to learn all the bits and pieces.

              Comment

              • Killer42
                Recognized Expert Expert
                • Oct 2006
                • 8429

                #22
                Originally posted by Wernerh
                Pure shot in the dark! I am as you can see a TOTAL newbie at this, so just starting to learn all the bits and pieces.
                I think all the textbox business is probably somewhat incidental to the main issue, which is that (unless things work a lot differently to VB6) there is no object in your application called Retail. Most likely, you need to change Retail.Range("g 5") to a proper reference to xlBook or one of the WorkSheet objects contained within it.

                Comment

                • rcollins
                  New Member
                  • Aug 2006
                  • 234

                  #23
                  I am having a similar problem in my code. Should be simple, what am I missing?
                  [Code=vb]
                  If Val(Standardize dAllocation.Tex t) = "HOUSE MEETINGS: " Then StandardizedAll ocationSumm.Tex t = "Consult with direct care staff ongoing medical concerns and plan of care."
                  End If
                  [/CODE]
                  Last edited by Killer42; Oct 9 '07, 09:53 PM.

                  Comment

                  • Killer42
                    Recognized Expert Expert
                    • Oct 2006
                    • 8429

                    #24
                    Originally posted by rcollins
                    [Code=vb]If Val(Standardize dAllocation.Tex t) = "HOUSE MEETINGS: " Then StandardizedAll ocationSumm.Tex t = "Consult with direct care staff ongoing medical concerns and plan of care."
                    End If
                    [/CODE]
                    Well, I don't know exacly what problem you are having. But I can see two fairly obvious problems with this code.
                    • The purpose of the Val() function is to take a string, convert it, and return a number. So it doesn't make any sense to compare the result to "HOUSE MEETINGS: ".
                    • Since you've coded the IF on a single line, it doesn't require (or perhaps it would be more precise to say it doesn't allow) an End If. To demonstrate the difference, these two pieces of code do precisely the same thing...
                      [CODE=vb]' Single-line...
                      If A = 1 Then B = 3

                      ' Multi-line...
                      If A = 1 Then
                      B = 3
                      End If[/CODE]

                    Comment

                    • rcollins
                      New Member
                      • Aug 2006
                      • 234

                      #25
                      So, per you example, this is what I have now
                      Code:
                      If StandardizedAllocation.Text = HOUSE MEETINGS: Then StandardizedAllocationSumm.Text = Consult with direct care staff ongoing medical concerns and plan of care.
                      I still don't get anything returned in the second text box.

                      Comment

                      • rcollins
                        New Member
                        • Aug 2006
                        • 234

                        #26
                        Here is the error I am getting now: "You can't reference a property or method for a control unless the control has the focus."
                        Here is my exact code for picking from two choises. I only get this error on the first choice, but don't get anything in the text box with the second one.

                        Code:
                        Private Sub StandardizedAllocation_AfterUpdate()
                        If StandardizedAllocation.Text = "HOUSE MEETINGS:" Then StandardizedAllocationSumm.Text = "Consult with direct care staff ongoing medical concerns and plan of care."
                        If StandardizedAllocation.Text = "MD Appt.Prep:" Then StandardizedAllocationSumm.Text = "Case file reviewed for pending medical appointment.  Plan of care reviewed and updated."
                         
                        End Sub

                        Comment

                        • rcollins
                          New Member
                          • Aug 2006
                          • 234

                          #27
                          Got it working, another member helped me. Thanks

                          Comment

                          • Killer42
                            Recognized Expert Expert
                            • Oct 2006
                            • 8429

                            #28
                            Originally posted by rcollins
                            "You can't reference a property or method for a control unless the control has the focus."
                            You said you were using VB6. VB6 does not report this error. Unless I'm gravely mistaken, this is an MS Access message.

                            Anyway, glad to hear you got it working.

                            Comment

                            Working...