Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004

    Unanswered: Specific Record Via Command Box

    I have a command button in a menu that I currently have set to open a an input form.

    I would much prefer, if it were possible, that when the user clicked on the Command button, a command box came up prompting them for the MemberID that they wished to display the record for. Once input, the form would open with this record specifically.

    Is this possible and how?

    Thankls Very Much,

  2. #2
    Join Date
    Mar 2004
    example :

    dim rst as recordset ! or DAO.recordset

    dim wantedMemID as string ' if MemberID is a string else long, integer
    identical to the fieldsetting where to search

    rst = Db.OpenRecordset("tbl........", dbOpenTable) ' indexes available
    by use of
    rst.index ="PrimaryKey" ' or any wanted index just the fieldname if
    not PrimaryKey
    place here the code to get Your MemberID in wantedMemID

    --------------- "=" wantedMemID ' record pointer moves to the required record
    if this field is unique, else it moves to the first
    Me!requery ' = me is form that wil be updated with de record source

  3. #3
    Join Date
    Mar 2004


    But erm, Dont hurt me but could I have that dumbed down or elabourated upon please. I have pretty much no Visual basic language or psudo code in my mind, therefore reading that it was hard to pick out things that I should change. For example.

  4. #4
    Join Date
    Mar 2004
    Dim Db as Database ' or instead of Database a DAO.Database

    Dim Rst as Recordset ' or instead of Recordset a DAO.Recordset

    Dim MemID as integer ' or string etc equal to the field MemberID

    Set Db = CurrentDb
    Set Rst = Db. OpenRecordset ("tablename") , dbOpenTable)

    ' dbOpenTable is required indexex will be available to set
    ' if MemberID is the PrimaryKey in your table then set the index

    Rst.Index = "PrimaryKey" ' else you write Rst.Index="MemberID"

    MemID = Me!fieldname ' the name of the inputfield in your form

    Rst.Seek "=" MemID

    remarks : if MemberID is indexed as a primarykey then Seek will
    point to the exact record, the same result as the
    field has uniqueness, in all other cases it will point to the
    first of the sequence.
    if the MemberID doesn´t exist then nothing will be found
    and Rst.EOF wil not be set in that case you can you use :

    if Rst.NoMatch = true Then
    End If

    hope this will help 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