Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2004
    Posts
    43

    Unanswered: Access Form with VB

    I hope somebody can help me with this...

    I have created a form in Access with a number if text fields. I would like the user to enter an item number in one of the fields, and then populate another field on the form with the item's weight. Both the item number and weight are in the same table, and it could be that there is more than one record with the same item number and weight (i.e. item number is not the primary key).

    Without knowing where to begin, I wrote the following code for my form...
    Code:
    Private Sub Text1_AfterUpdate()
    
    Dim artikel As Double
    Dim strSQL As String
    
    artikel = Text1.Value
    
    strSQL = "SELECT BAAN_IMPORT.U_ARTIKEL, BAAN_IMPORT.GEWICHT " & _
             "FROM BAAN_IMPORT " & _
             "GROUP BY BAAN_IMPORT.U_ARTIKEL, BAAN_IMPORT.GEWICHT " & _
             "HAVING BAAN_IMPORT.U_ARTIKEL=" & artikel & ";"
    
    'know idea what to do next!!!???
    
    'Text2.Value = GEWICHT field returned by the above query...
    
    End Sub
    I am not sure how to take the second field of my query results, and use it to populate the second text field on my form...?

    Any help would be greatly appreciated...
    Steve

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    have a look at the DLOOKUP() function.

    it goes something like this:

    text2 = dlookup("[GEWICHT]", "[BAAN_IMPORT]", "U_ARTIKEL=" & artikel)

    izy
    currently using SS 2008R2

Posting Permissions

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