Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2006
    Posts
    2

    Unanswered: pass value from text box to combobox force AfterUpdate Event

    Hi,
    When I pass a value from MyTextBox to MyComboBox using:

    Me.MyTextBox = Me.MyComboBox


    It does Not trigger the AfterUpdate Event of the ComboBox


    I need it to! Any Suggestions??


    I have tried: copy and pasting by but that creates a problem


    Me.MyTextBox = BarCodeData$ 'passes the variable value to MyTextBox
    Me.MyTextBox .SetFocus
    Me.MyTextBox .SelStart = 0
    Me.MyTextBox .SelLength = Len(Me.MyTextBox ) + 1
    SendKeys "^c" 'copies the value of of MyTextBox


    as soon as I add the below line, it no longer copies the value in
    MyTextBox
    Me.MyComboBox.SetFocus


    The onEnter Event of MyComboBox has the following code that works fine.


    Private Sub cboLookupPart_Enter()


    Me.MyComboBox.SetFocus
    Me.MyComboBox.SelStart = 0
    Me.MyComboBox.SelLength = Len(Me.MyComboBox.Text)
    SendKeys "^v"


    End Sub


    If I ran all the code above, all works but the "Copy" and thus anything
    that may be in the clipboard is pasted into MyComboBox, and the
    AfterUpDate of MyComboBox triggers.


    I know that there are compelling reason NOT to use the SendKeys but I
    was just trying something


    What I'd really like to do is eliminate MyTextBox and pass the Variable
    directly to MyComboBox:


    Me.MyComboBox= BarCodeData$


    And have it force the AfterUpdate Event of MyComboBox


    Eagerly awaiting suggestions!


    Thank you,
    Robert Bloomfield

  2. #2
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,423
    Provided Answers: 8
    try



    Me.MyTextBox = Me.MyComboBox
    call MyComboBox_AfterUpdate()
    hope this help

    See clear as mud


    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.

  3. #3
    Join Date
    Aug 2006
    Posts
    2
    Hi StePhan,
    The call to the AfterUpdate Event of the ComboBox worked EXCEPT for one thing and that is the BIGGEST reason I was passing it to the ComboBox. There is a "Limit To List" validation property on the ComboBox and that is not run when I use your method.

    The code that runs on the AfterUpdate Event is:

    Private Sub cboLookupPart_AfterUpdate()
    ' Find the record
    Dim rs As Object
    Set rs = Me.Recordset.Clone
    rs.FindFirst "[PR-NO] = '" & Me![cboLookupPart] & "'"
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
    Me![cboLookupPart] = ""

    'Set forcus on Sub Form
    Forms!frmPropertyScanOutByPart!frmTransactionSubFo rmScanOutByPart.SetFocus
    End Sub

    I could have run this code directly from within the first code example without passing it to the combobox but I wanted the validation test of "Limit To List" because i don't know how to write the code to test for this and passing it to the ComboBox seemed easy... well.... 2 days later, and still not working, I'm not so sure it was the easy way out:

    What I am doing is an inventory System and implementing Barcode scanning:
    The code that is actived by the scan is below:

    Private Sub txtScanBox_KeyDown(KeyCode As Integer, Shift As Integer)

    If KeyCode <> 13 Then Exit Sub
    BC$ = txtScanBox.Text
    If Len(BC$) Then
    BarCodeType$ = Left$(BC$, 1) 'parses 1st character of barcode scan which is the Code ID
    BarCodeData$ = Mid$(BC$, 2) 'parses Barcode Number characters of barcode scan
    Select Case BarCodeType 'case determines which barcode type it is - UPC or Code 39
    Case "b" 'Tests for Code 39

    Me!cboLookupPart = BarCodeData$ 'Sends parsed Bar Code Number To ComboBox, Bound to Code 39 PartNumber Field
    Call cboLookupPart_AfterUpdate 'Calls AfterUpdate Event on ComboBox which finds and bookmarks Part and runs validation on "Limit To List" Property
    Me![txtScanBox] = ""

    Case "a" 'Tests for UPC
    Me!cboLookupPartUPC = BarCodeData$ 'Same as above, Different ComboBox, Bound to UPC PartNumber Field
    Call cboLookupPartUPC_AfterUpdate
    Me![txtScanBox] = ""

    Case Else
    End Select

    End If
    End Sub

    Any new suggestion to get the ComboBox to test the "limit to List" validation?

    Or... How to write the code to test for whether the scanned part number in in the part database? and then comes the error handling code which would give the message " The Scanned number is not found in the database, please try again!" This code would have to be placed within the above case statements and for me that got tricky.

    Thank you for your help! This is a WONDERFUL forum
    Robert Bloomfield

  4. #4
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Did anyone happen to notice that the assignment is wrong??? You're not assigning TO the combo, you're assigning FROM the combo ... I just assume that this is just a typo ...

    I think that for you to trigger the limit to list check, you'll have to something like:

    Mycombobox.setfocus
    mycombobox.Text=MyTextbox.text


    If you use the .Value property, no events get triggered ...
    Back to Access ... ADO is not the way to go for speed ...

Posting Permissions

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