Results 1 to 34 of 34

Thread: Which is right? SOLVED!!!!!

  1. #1

    Thread Starter
    Addicted Member Bazzlad's Avatar
    Join Date
    Jun 2003
    Posts
    227

    Lightbulb Which is right? SOLVED!!!!!

    To stop fields having blank values which is right?

    blah blah on click

    if

    A) text6.value = false
    B) text6.value = Null
    C) text6.value = 0

    then

    Etc

    A B or C?
    or is there another?

    NB must be done in this style, due to forms opening and closing.
    Last edited by Bazzlad; Jul 1st, 2003 at 07:17 AM.
    *And you'll see, Everything you stand for is fake*
    http://www.rhesusrock.com

  2. #2
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089
    Code:
    if trim(Text1.Text) = "" then
      Msgbox "text1 is empty"
    else
       'Do processing
    end if

  3. #3

    Thread Starter
    Addicted Member Bazzlad's Avatar
    Join Date
    Jun 2003
    Posts
    227
    apparantly I:
    Can't reference a property unless it has the focus
    Nb using VBA, and the text box is hidden......





    If Text6.Value = 0 Then
    responce = MsgBox("Enter a Customer Name", vbOKOnly, "You messed up!")
    Else: GoTo 10

    10: blah

    end if

    that works, but only if i put my text boxes default value as 0..
    which I don't want to do.
    *And you'll see, Everything you stand for is fake*
    http://www.rhesusrock.com

  4. #4
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089
    VBA. U didnt mention this in the first post, or maybe I didnt pick it up .Sorry bud, no idea of it

  5. #5

    Thread Starter
    Addicted Member Bazzlad's Avatar
    Join Date
    Jun 2003
    Posts
    227
    thats why i'm stuck...it's like VB. but different
    Lol, your code would have worked if my text wasn't hidden and taking its value from a combo box
    help anyone?
    *And you'll see, Everything you stand for is fake*
    http://www.rhesusrock.com

  6. #6
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    I don't get your problem.
    I used this code in VBA:
    VB Code:
    1. Private Sub UserForm_Click()
    2. If TextBox1.Text = "" Then
    3. MsgBox "TextBox is empty"
    4. Else
    5. MsgBox "TextBox is not empty"
    6. End If
    7. End Sub
    I did set the TextBox1. visible and .enabled to False, whenever I click on the UserForm, it says "..is empty" (if the Textbox is empty!).
    What'S your problem?
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  7. #7

    Thread Starter
    Addicted Member Bazzlad's Avatar
    Join Date
    Jun 2003
    Posts
    227
    "and you can't reference a property unless it has the focus"

    Also, the hidden textbox is taking its value from a combo box..
    txtbox.value = combobox.value

    and for soem reason...it doesnt like it//
    *And you'll see, Everything you stand for is fake*
    http://www.rhesusrock.com

  8. #8

    Thread Starter
    Addicted Member Bazzlad's Avatar
    Join Date
    Jun 2003
    Posts
    227

    GRRRRRRRRRRR

    **** it, here's my full code for that section
    (and please don't shout about my goto's .....

    Private Sub Command8_Click()
    On Error GoTo Err_Command8_Click


    If Text6.Value = 0 Then
    responce = MsgBox("Enter a Customer Name", vbOKOnly, "You messed up!")

    Else: GoTo 10


    10
    If IMEI.Value = 0 Then
    responce = MsgBox("Enter an IMEI Number", vbOKOnly, "You messed up!")
    IMEI.SetFocus
    Else: GoTo 20

    20

    If Make.Value = 0 Then
    responce = MsgBox("Enter an Phone Make", vbOKOnly, "You messed up!")
    Make.SetFocus
    Else: GoTo 30

    30



    Dim stDocName As String
    Dim stLinkCriteria As String

    me.visible =false
    stDocName = "frmrepair"

    DoCmd.OpenForm stDocName, , , stLinkCriteria
    stDocName = "frmrepair"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    DoCmd.GoToRecord , , acNewRec
    [Forms]![frmrepair]![Text14] = [Forms]![frmphone]![IMEI]
    [Forms]![frmrepair]![Customer Name] = [Forms]![frmphone]![Text6]
    [Forms]![frmrepair]![Check25] = [Forms]![frmphone]![Warranty]


    End If
    End If
    End If

    Exit_Command8_Click:
    Exit Sub

    Err_Command8_Click:
    MsgBox Err.Description
    Resume Exit_Command8_Click

    End Sub


    The problem I'm having is this...
    If I put in a username but leave the IMEI out, the ******* thing still decides to hide my form and load the other, on the other form IMEI.value is required = error message and stuck.

    Please bear in mind
    text6 is invisible and reads from the combo box
    addphonecn.combo

    I can't see what's wrong....
    *And you'll see, Everything you stand for is fake*
    http://www.rhesusrock.com

  9. #9
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    how should a Textbox take something into .Value if it doesn'T have a .Value properiety?
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  10. #10
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    What the f***
    VB Code:
    1. Private Sub Command8_Click()
    2. On Error GoTo Err_Command8_Click
    3.  
    4. 'What's Text6.Value, shouldn'T it be .Text?
    5. If Text6.Value = 0 Then
    6. responce = MsgBox("Enter a Customer Name", vbOKOnly, "You messed up!")
    7.  
    8. Else: GoTo 10
    9. 'If you come here, there is way way to go around "10" so forget the GoTo
    10.  
    11. 10
    12. 'this part will only be checked if you failed on the first check!
    13. If IMEI.Value = 0 Then
    14. responce = MsgBox("Enter an IMEI Number", vbOKOnly, "You messed up!")
    15. IMEI.SetFocus
    16. Else: GoTo 20
    17. 'If you come here, there is way way to go around "20" so forget the GoTo
    18. 20
    19. 'this part will only be checked if you failed on the first two checks!
    20. If Make.Value = 0 Then
    21. responce = MsgBox("Enter an Phone Make", vbOKOnly, "You messed up!")
    22. Make.SetFocus
    23. Else: GoTo 30
    24. 'If you come here, there is way way to go around "30" so forget the GoTo
    25.  
    26. 30
    27.  
    28.  
    29. 'this part will only be done if all checks above failed!
    30. Dim stDocName As String
    31. Dim stLinkCriteria As String
    32.  
    33. me.visible =false
    34. stDocName = "frmrepair"
    35.  
    36. DoCmd.OpenForm stDocName, , , stLinkCriteria
    37. stDocName = "frmrepair"
    38. DoCmd.OpenForm stDocName, , , stLinkCriteria
    39. DoCmd.GoToRecord , , acNewRec
    40. [Forms]![frmrepair]![Text14] = [Forms]![frmphone]![IMEI]
    41. [Forms]![frmrepair]![Customer Name] = [Forms]![frmphone]![Text6]
    42. [Forms]![frmrepair]![Check25] = [Forms]![frmphone]![Warranty]
    43.  
    44.  
    45. End If
    46. End If
    47. End If
    48.  
    49. Exit_Command8_Click:
    50. Exit Sub
    51.  
    52. Err_Command8_Click:
    53. MsgBox Err.Description
    54. Resume Exit_Command8_Click
    55.  
    56. End Sub
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  11. #11

    Thread Starter
    Addicted Member Bazzlad's Avatar
    Join Date
    Jun 2003
    Posts
    227
    It does. Doesn't it?
    And if not, what bloody code do I use instead?
    When I originally used .text I got that damn error message.
    *And you'll see, Everything you stand for is fake*
    http://www.rhesusrock.com

  12. #12
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    Sorry, you're right Textboxes have an .Value.
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  13. #13

    Thread Starter
    Addicted Member Bazzlad's Avatar
    Join Date
    Jun 2003
    Posts
    227
    'this part will only be done if all checks above failed!
    thats the idea.
    If the test is failed it means the text boxes have a value in them, thus not causing a conflict with the next form, which takes the values from this form and locks the boxes. Bear in mind they are required, so an empty, locked text box = me.screwed.

    It's a weird one, and my coding isn't exactly, hmmm, generic, meaning there are a lot of **** ups in it!!

    Any ideas?
    *And you'll see, Everything you stand for is fake*
    http://www.rhesusrock.com

  14. #14
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    Try Checking if .Value=""
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  15. #15

    Thread Starter
    Addicted Member Bazzlad's Avatar
    Join Date
    Jun 2003
    Posts
    227
    No dice :'(

    If you know another way, even if the code is totally different, I'm willing to try,

    All I need is for it to check the 3 textboxes for data (they MUST have data) then if they do, load the next form...


    Thanx
    *And you'll see, Everything you stand for is fake*
    http://www.rhesusrock.com

  16. #16
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    This way it looks better (wihout those useless GoTo's
    VB Code:
    1. Private Sub Command8_Click()
    2. On Error GoTo Err_Command8_Click
    3.  
    4.  
    5. If Text6.Value = ""Then
    6.    responce = MsgBox("Enter a Customer Name", vbOKOnly, "You messed up!")
    7. Else
    8.    If IMEI.Value = "" Then
    9.       responce = MsgBox("Enter an IMEI Number", vbOKOnly, "You messed up!")
    10.       IMEI.SetFocus
    11.    Else
    12.       If Make.Value ="" Then
    13.          responce = MsgBox("Enter an Phone Make", vbOKOnly, "You messed up!")
    14.          Make.SetFocus
    15.       Else
    16.          Dim stDocName As String
    17.          Dim stLinkCriteria As String
    18.          me.visible =false
    19.          stDocName = "frmrepair"
    20.  
    21.         DoCmd.OpenForm stDocName, , , stLinkCriteria
    22.         stDocName = "frmrepair"
    23.         DoCmd.OpenForm stDocName, , , stLinkCriteria
    24.         DoCmd.GoToRecord , , acNewRec
    25.         [Forms]![frmrepair]![Text14] = [Forms]![frmphone]![IMEI]
    26.         [Forms]![frmrepair]![Customer Name] = [Forms]![frmphone]![Text6]
    27.         [Forms]![frmrepair]![Check25] = [Forms]![frmphone]![Warranty]
    28.  
    29.  
    30.       End If
    31.    End If
    32. End If
    33.  
    34. Exit_Command8_Click:
    35. Exit Sub
    36.  
    37. Err_Command8_Click:
    38. MsgBox Err.Description
    39. Resume Exit_Command8_Click
    40.  
    41. End Sub
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  17. #17
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    What'S happening when you use the check on .Value="", and what is the .Value (use a debug.print to check!)
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  18. #18
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    I checked the code (using te "" Check!) (except the part after the End If'S) in VBA, if any of the three Textboxes is Empty the Sub will be exited, if there is anything in there, the part after the End If'sd will be done!
    See after my lunch break!
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  19. #19

    Thread Starter
    Addicted Member Bazzlad's Avatar
    Join Date
    Jun 2003
    Posts
    227

    this is ridiculous

    with your code, it just opens the next form, but blank with the error of customer_name cannot be left empty.
    Debug.print?
    never used it!
    *And you'll see, Everything you stand for is fake*
    http://www.rhesusrock.com

  20. #20
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: this is ridiculous

    Originally posted by Bazzlad
    ...but blank with the error of customer_name cannot be left empty.
    I don'T understand that part.
    So "my" code worked for the first part?

    Use "Debug.Print Var" to print the value of Var into the Direct Window (part of the IDE) .
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  21. #21

    Thread Starter
    Addicted Member Bazzlad's Avatar
    Join Date
    Jun 2003
    Posts
    227
    It opens form repair (blank) as it should
    but the customer name and IMEI number are Both empty
    that cant happen, as I cant, nor do I want to, put in those values manually still cant figure:
    Debug.Print Var; Text6.Value?
    wheres the value appear?
    *And you'll see, Everything you stand for is fake*
    http://www.rhesusrock.com

  22. #22
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    Correct Statement for Debug.Print
    VB Code:
    1. Debug.Print Text6.Value
    It will be printed onto the DirectWindow(I hope that'S the correct English name for it), if it is not visible in your VB-IDE you have to select it visible.

    Looking at the code, you only try to handover two of the checked values (Customer_Name and IMEI), the third one checked was "make" but you try to hanover "Warranty".
    So, you not getting any correct handing over from one form to the other.
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  23. #23
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    To handover from one Form to the other I use:
    VB Code:
    1. RecievingForm.Text6.Value = SendingForm.TextBox1.Value
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  24. #24

    Thread Starter
    Addicted Member Bazzlad's Avatar
    Join Date
    Jun 2003
    Posts
    227
    ahh yes, I want warranty handed over, but it does not have to have a value, in that instance 0 = fine.
    I use MAKE.text on a different form later is it is needed,
    can;t find VB-IDE, I am using VBA, that make any difference?
    *And you'll see, Everything you stand for is fake*
    http://www.rhesusrock.com

  25. #25

    Thread Starter
    Addicted Member Bazzlad's Avatar
    Join Date
    Jun 2003
    Posts
    227
    What I need to solve it is this...

    I need to know what figure/number/name is used for an empty textbox value...
    *And you'll see, Everything you stand for is fake*
    http://www.rhesusrock.com

  26. #26

    Thread Starter
    Addicted Member Bazzlad's Avatar
    Join Date
    Jun 2003
    Posts
    227
    I think it's = false
    So the problem lies in my multiple If statement...
    is there a better way to make more than one if statement?
    can I use select case?
    Bazz
    *And you'll see, Everything you stand for is fake*
    http://www.rhesusrock.com

  27. #27
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    I ment VBA-IDE, the keyboardcommand to show the DirectWindow is CTRL-G.

    The Check should be for =""
    And the problem you discribed is more like a false handover of the values from one form to the other. Try this code:
    VB Code:
    1. Private Sub Command8_Click()
    2. On Error GoTo Err_Command8_Click
    3.  
    4.  
    5. If Text6.Value = ""Then
    6.    responce = MsgBox("Enter a Customer Name", vbOKOnly, "You messed up!")
    7. Else
    8.    If IMEI.Value = "" Then
    9.       responce = MsgBox("Enter an IMEI Number", vbOKOnly, "You messed up!")
    10.       IMEI.SetFocus
    11.    Else
    12.       If Make.Value ="" Then
    13.          responce = MsgBox("Enter an Phone Make", vbOKOnly, "You messed up!")
    14.          Make.SetFocus
    15.       Else
    16.          Dim stDocName As String
    17.          Dim stLinkCriteria As String
    18.          me.visible =false
    19.          stDocName = "frmrepair"
    20.  
    21.         DoCmd.OpenForm stDocName, , , stLinkCriteria
    22.         stDocName = "frmrepair"
    23.         DoCmd.OpenForm stDocName, , , stLinkCriteria
    24.         DoCmd.GoToRecord , , acNewRec
    25.         'I changed something here, not sure if you really need the "Forms." part.
    26.         Forms.frmrepair.Text14.Value = Forms.frmphone.IMEI.Value
    27.         Forms.frmrepair.Customer Name.Value = Forms.frmphone.Text6.Value
    28.         Forms.frmrepair.Check25.Value = Forms.frmphone.Warranty.Value
    29.  
    30.  
    31.       End If
    32.    End If
    33. End If
    34.  
    35. Exit_Command8_Click:
    36. Exit Sub
    37.  
    38. Err_Command8_Click:
    39. MsgBox Err.Description
    40. Resume Exit_Command8_Click
    41.  
    42. End Sub
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  28. #28

    Thread Starter
    Addicted Member Bazzlad's Avatar
    Join Date
    Jun 2003
    Posts
    227

    YEAH!

    I figured it out!!!

    Thanks a hell of a lot to opius who helped me loads!
    This is the working code!!



    Private Sub Command8_Click()
    On Error GoTo Err_Command8_Click

    If Text6.Value = False Then
    responce = MsgBox("Enter a Customer Name", vbOKOnly, "You messed up!")
    Else
    GoTo 10
    Exit Sub

    10
    If IMEI.Value >= "" Then
    GoTo 20
    Else: responce = MsgBox("Enter an IMEI Number", vbOKOnly, "You messed up!")
    Exit Sub

    20
    If Make.Value >= "" Then
    GoTo 30
    Else: responce = MsgBox("Enter an Phone Make", vbOKOnly, "You messed up!")
    Exit Sub

    30
    Dim stDocName As String
    Dim stLinkCriteria As String
    Me.Visible = False
    stDocName = "frmrepair"

    DoCmd.OpenForm stDocName, , , stLinkCriteria
    stDocName = "frmrepair"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    DoCmd.GoToRecord , , acNewRec
    [Forms]![frmrepair]![Text14] = [Forms]![frmphone]![IMEI]
    [Forms]![frmrepair]![Customer Name] = [Forms]![frmphone]![Text6]
    [Forms]![frmrepair]![Check25] = [Forms]![frmphone]![Warranty]


    End If
    End If
    End If

    Exit_Command8_Click:
    Exit Sub

    Err_Command8_Click:
    MsgBox Err.Description
    Resume Exit_Command8_Click

    End Sub
    *And you'll see, Everything you stand for is fake*
    http://www.rhesusrock.com

  29. #29
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    Just curious, what MS-Product are you using?
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  30. #30

    Thread Starter
    Addicted Member Bazzlad's Avatar
    Join Date
    Jun 2003
    Posts
    227
    Access 2000...
    I don't get why text6.value HAS to be .false
    and the others HAVE to be >=
    It makes no sense, but hey, it works
    Thanx again
    *And you'll see, Everything you stand for is fake*
    http://www.rhesusrock.com

  31. #31
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    Oh, Access, didn'T get that. That'S reason for the "false Handover", I did it in EXCEL.

    I can'T tell the difference between FALSE and "", but the difference between = and >= is obvious. The first check (Terxt6) was if there is no input (if that statement is correct the sub will be exited after showing trhe messagebox). The other checks are the way around, that is if something has been set to those Textboxes the check is valid and you do your GoTo, only if the check fails the Messagebox comes up.
    This way you get three messageboxes if all textboxes are empty, in my solution the first one would have thrown you out!
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  32. #32

    Thread Starter
    Addicted Member Bazzlad's Avatar
    Join Date
    Jun 2003
    Posts
    227
    3 message boxes???
    No you don't!!
    I used exit sub after each if, so if a messagebox shows, it exits automatically.
    *And you'll see, Everything you stand for is fake*
    http://www.rhesusrock.com

  33. #33
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    You're right, you do exit each time,
    it's hard to read this jumping jack code
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  34. #34

    Thread Starter
    Addicted Member Bazzlad's Avatar
    Join Date
    Jun 2003
    Posts
    227
    yeah, its a little old skool BASIC he he...
    my old teACHER would lamp me for using so many GOTOs..
    in fact he'd lamp me for using any.....
    *And you'll see, Everything you stand for is fake*
    http://www.rhesusrock.com

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