Results 1 to 9 of 9
  1. #1
    Join Date
    May 2002
    Posts
    28

    Unanswered: dlookup or any search

    Hi,
    I need to puplate two value to find third value.
    my example


    I want to enter name and age in form to get his blood group.

    How can i use Dlookup or any other find type.

  2. #2
    Join Date
    Nov 2001
    Posts
    336
    Hi,

    Sure you can:

    Dim varX As Variant
    Dim strLastName as String
    Dim intAge as Integer

    strLastName="Smith"
    intAge=25

    varX = DLookup("tblPatients", "BloodGroup", _
    "LastName ='" & strLastName & "' And Age=" & intAge)

    Igor

  3. #3
    Join Date
    May 2002
    Posts
    28

    plz see comment

    Hi,
    Where to put iam using Access97 .the code i put in name or blood goup or age.
    plz make clear

  4. #4
    Join Date
    Nov 2001
    Posts
    336
    Hi,

    Possibly you have a form with textboxes for Name and Age: txtName and txtAge. So create a command button and in click event put the following code:

    Dim varX As Variant

    varX = DLookup("tblPatients", "BloodGroup", _
    "LastName ='" & txtName & "' And Age=" & txtAge)
    msgbox nz(varX,"Not found)"

    Igor

  5. #5
    Join Date
    May 2002
    Posts
    28

    Unhappy No work

    Hi my dear
    I create bottom i put the code not work
    So I wll give all i have text.

    I put your code

    varX = DLookup("table3", "BloodGroup", _
    "Name ='" & Text12 & "' And Age=" & Text14)
    MsgBox Nz(varX, "Not found")





    Name=text12
    age=text14
    tablename=table3.



    plz help me

  6. #6
    Join Date
    Nov 2001
    Posts
    336
    May you post here the structure of the TABLE3?
    Where did you create the command button with the code on click event?

    Igor

  7. #7
    Join Date
    May 2002
    Posts
    28

    i post mdb

    hi my mdb
    Attached Files Attached Files

  8. #8
    Join Date
    Nov 2001
    Posts
    336
    Hi,

    I looked at your mdb file.
    I would suugest a couple of minor enhancements:
    1. Give your textboxes more descriptive names: txtNames and txtAge
    2. Change datatype of Age in table4 to Numeric: Integer instead of Text.

    Then try the code below:


    Private Sub Command20_Click()

    Dim varx As Variant

    varx = DLookup("BloodGroup", "table4", _
    "Name ='" & Me.txtName & "' And Age=" & Me.txtAge)
    MsgBox Nz(varx, "Not found")

    End Sub


    Igor

  9. #9
    Join Date
    May 2002
    Posts
    28

    Unhappy

    to IGelin

    Thanks alot ,I real happy with your help.Can i post some more question
    example
    to add roomno.
    roomno .(roomno. is integer)



    this code is right
    varx = DLookup("BloodGroup", "table4", _
    "Name ='" & Me.txtName & "' And Age=" & Me.txtAge _
    And room=" & Me.txtroom )

Posting Permissions

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