Consulting

Results 1 to 5 of 5

Thread: assistance from experts to fixing theses codes

  1. #1

    assistance from experts to fixing theses codes

    hi
    when I search in the internet like my question . I 've found theses codes but there is something . it doesn't work
    the idea of code shows message when fill values in textbox1 after fill combobox1,2,3 they should match with col A,B,C if the values are filled in textbox1,2 bigger than what are existed in col D then should message box the value is exceeded and show the real value for specific item . so if any body can fix it or alternative code it will be a great
    
    
    Function MatchingRowNumber(Brand As String, _
                               Typ As String, _
                               Origin As String) As Long
        ' 290
    
    
        Dim Fun As Long
    
    
        With Worksheet("List")
            ' search for the match here
            ' Fun interim result
        End With
        MatchingRowNumber = Fun
    End Function
    
    
    Private Function IsAvailable(ByVal Qty As Long) As Boolean
        ' 290
    
    
        Dim R           As Long
        Dim AvailQty    As Long
    
    
        R = MatchingRowNumber(ComboBox1.Value, _
                              ComboBox2.Value, _
                              ComboBox3.Value)
        AvailQty = List.Cells(R, "D").Value
        If AvailQty < Qty Then
            MsgBox "The quantity you entered exceeds availability." & vbCr & _
                   "Available quantity is " & AvailQty & ".", _
                   vbInformation, "Limited availability"
        Else
            IsAvailable = True
        End If
    End Function
    
    
    Private Sub TextBox1_Change()
        ' 290
    
    
        If IsAvailable(TextBox1.Value) Then
            ' continue with the program
        Else
            ' return to the textbox
            TextBox1.SetFocus
        End If
    End Sub

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    It's much easier to help if you attach a small sample workbook with some data and the existing macros
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    thanks for your interesting
    there is another code . it copies data from userform to sheet INV , but I want before copy data . it should check the values are existed in COL D in sheet LIST if the item contain value into textbox1 or 2 bigger than what are existed in COL D in sheet LIST then should show message the number is exceeded and show me the real qty is available .
    Attached Files Attached Files

  4. #4
    is there any help?

  5. #5
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,635
    Why don't you show the user the availabe stock before (s)he can choose an amount ?
    Why don't you restricht the user's choice to the available stock ?

Posting Permissions

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