Results 1 to 6 of 6

Thread: "Or" Operator problem

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2001
    Posts
    12

    "Or" Operator problem

    This is my code:


    Private Sub cmdAdd_Click()

    If rs2.NoMatch Then
    If txtAuthor.Text = " " Or txtName.Text = " " Or txtAddress.Text = " " Then
    rs1.AddNew
    rs1.Fields("Comment") = "Insufficient Author Data"
    rs1.Update

    Else
    rs1.AddNew.......

    The problem is that if either of the author, name, or address text boxes are empty on my form, the code just jumps down to the Else instead of rs1.AddNew (after Then)

    What am I doing wrong please???
    Else

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    i am thinking maybe because you have

    Code:
    If txtAuthor.Text = " " Or txtName.Text = " " Or txtAddress.Text = " " Then
    maybe try to put in

    Code:
    If txtAuthor.Text = "" Or txtName.Text = "" Or txtAddress.Text = "" Then
    it looks like you are checking for a space where you really are looking for empty strings.

  3. #3
    Addicted Member Pickler's Avatar
    Join Date
    May 2001
    Location
    nffanb
    Posts
    248
    If txtAuthor.Text = " " Or txtName.Text = " " Or txtAddress.Text = " " Then
    should be
    If txtAuthor.Text = "" Or txtName.Text = "" Or txtAddress.Text = "" Then

    ( no spaces between "" )

  4. #4

    Thread Starter
    New Member
    Join Date
    Oct 2001
    Posts
    12
    Your a living legend!

    Appreciate that.

  5. #5
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    You could try dropping the ELSE too.

    ie.
    VB Code:
    1. Private Sub cmdAdd_Click()
    2.  
    3. If rs2.NoMatch Then
    4.   If txtAuthor.Text = "" Or txtName.Text = "" Or txtAddress.Text = "" Then
    5.   rs1.AddNew
    6.   rs1.Fields("Comment") = "Insufficient Author Data"
    7.   rs1.Update
    8.   [b]Exit Sub[/b]
    9.  End If
    10. End If
    11. '
    12. rs1.AddNew  'Whatever else here
    13. '
    14. End Sub
    Last edited by Bruce Fox; Apr 8th, 2002 at 11:29 PM.

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Also try putting in a breakpoint there and checking the values when it breaks. It's probably because of the spaces.

Posting Permissions

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



Click Here to Expand Forum to Full Width