Results 1 to 3 of 3
  1. #1
    beaurou is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    16

    Problem with text box

    I have a from with 4 textboxes and a cmd button on it:



    TextHex0
    TextHex1
    TextEng0
    TextEng1

    I want to use the 4 boxes as input from the user to make a calculation. All the textboxes need to have a value and the TextEng(x) must be numeric.

    This is where I stand so far:

    Private Sub cmdCalculate_Click()
    Dim iLoop As Integer
    Dim iNumOfSamples As Integer
    Dim strMessage As String
    Dim varEng As Variant

    strMessage = "You must have a minimum of 2 values, "
    strMessage = strMessage & "in the positions 1 and 2 " & Chr(13) & Chr(10)
    strMessage = strMessage & " for both HEX and ENGINEERING"

    'Make sure you have a minimum of two values for each HEX and ENGINEERING
    For iLoop = 0 To 1
    If (Me.Controls("Texthex" & iLoop).Value = "" Or Me.Controls("TextEng" & iLoop).Value = "") Then
    MsgBox strMessage, vbOKOnly, "Input Values"
    Exit Sub
    End If
    iNumOfSamples = iNumOfSamples + 1
    Next iLoop

    'Make sure the engineering values are numbers
    For iLoop = 0 To iNumOfSamples - 1
    varEng = Me.Controls("TextEng" & iLoop).Value
    If (Not IsNumeric(varEng)) Then
    MsgBox "Engineering values must be numeric", vbOKOnly, "Input values"
    Exit Sub
    End If
    Next iLoop
    End Sub


    The problem that I have is that the first part produce no result if I have a blank textbox, but the second part work fine, if you type a letter in one of the TextENG() textbox the error message apear.

    Idealy if I have any blank the top strMessage should popup.

    Any idea will be welcome.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Don't check for "", check for Null or handle both.

    If Me.Controls("Texthex" & iLoop) & "" = "" Or Me.Controls("TextEng" & iLoop) & "" = "" Then
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    beaurou is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    16
    Thank you very much is work perfectly.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 10-31-2012, 11:52 AM
  2. Replies: 2
    Last Post: 06-14-2010, 03:25 PM
  3. query problem i have a problem wi
    By maxx3 in forum Queries
    Replies: 0
    Last Post: 06-29-2009, 02:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums