Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Access 2000 - Open form and find record

Access 2000 - Open form and find record

Access 2000 - Open form and find record

I am an Access 97 developer and I am trying to open a form and find a record based on the value of another form.  

I have tried using the same syntax listed below but it does not like the nomatch property.  

Does anyone have the code which opens one form from another and goes to a specific record?

' Declare Variables
Dim FormName As String
Dim RecordNumber As Variant
Dim frm As Form
Dim rst As Recordset
Dim strCriteria As String

' Store the personid field to the variable record number
RecordNumber = Me![personid]
' Store the name of the form you want to open
FormName = "F_Person"

' Open the form
DoCmd.OpenForm FormName

' Create a recordset based on the form just opened and find the first matching record
Set frm = Forms(FormName)
strCriteria = "[PersonId] Like '*" & RecordNumber & "*'"
Set rst = frm.RecordsetClone
rst.FindFirst strCriteria

' if there is no matching records then put up a message otherwise go to the selected record.  
If rst.NoMatch Then
    MsgBox "Coundn't find record"
    frm.Bookmark = rst.Bookmark
End If

RE: Access 2000 - Open form and find record

Open the code window in design view.
then click on the following line and press the F9 key:
Set frm = Forms(FormName)

Run it so it will go through the code and it should stop on that line.
then Press Ctrl-G to bring up the Immediate window.
to move to the next line Press F8
Now you can examine whats in each variable, put you mouse over the "strCriteria" and move is slowly after you F8 past it one line.
See if it has what it needs.
Also double check that there is infact a "Recordnumber" in your table the same as the one you are passing.

DougP, MCP
 Ask me how Bar-codes can help you be more productive.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close