Results 1 to 2 of 2
  1. #1
    Join Date
    May 2004
    Posts
    133

    Unanswered: Newbie need help: put search result of one form to another one using openargs

    Hi all,
    I'm new to Access VBA and now I'm learning access VBA using "Microsoft access VBA for dummies" book. When I'm learning about the basic of openargs, I have the following problem:
    As guided in the book, in the customers form, I put the following code on the lastname control's click event:
    Private Sub LastName_Click()
    Dim locate
    Dim rs As New Recordset
    Dim frm As DAO.Recordset

    locate = InputBox("please input your lastname here:", "HAL VIETNAM")
    rs.Open _
    " select customerid from customers where " & _
    " lastname like '" & locate & "%'", _
    CurrentProject.Connection, adOpenKeyset, adLockOptimistic
    If rs.EOF Then
    MsgBox " nothing found"
    Else
    rs.MoveLast
    If rs.RecordCount > 1 Then
    DoCmd.OpenForm _
    FormName:="searchform", _
    OpenArgs:=" lastname like '" & locate & "*'"
    Else
    Set frm = Me.RecordsetClone
    frm.FindFirst " lastname like '" & locate & "*'"
    Me.Bookmark = frm.Bookmark
    End If
    End If
    End Sub

    In the "seachform" form's load event, I put the following code:
    Private Sub Form_Load()
    With List0
    .RowSource = "select customerid, " & _
    "lastname & ', ' & firstname as Name, " & _
    " from customers where " & Me.OpenArgs
    .ColumnCount = 3
    .ColumnHeads = True
    .ColumnWidths = "0;1.5 in;1.5 in"
    .Requery
    End With
    End Sub

    But it don't work.
    Could anyone tell me something is wrong and correct it for me?
    I attached the axample file on this post.
    many thanks.
    Attached Files Attached Files

  2. #2
    Join Date
    May 2004
    Posts
    133
    Could anyone can help me on this problem?
    I really need your help.
    thank you.

Posting Permissions

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