Open Specific Record

G

Guest

This will probably sound rather dumb, but I'm having a problem getting a form
to open to a specific record.

I do a search based on a query and the query returns the record(s) to a
form. I have a command button to open the selected record, but instead it
opens a new record which is not what I need. Suggestions?

Private Sub cmdOpenRecord_Click()
Dim stdocname As String
Dim stlinkcriteria As String

stdocname = "f_Projects"
DoCmd.OpenForm stdocname, , , where = Me![ProjectNo] = "", , , stlinkcriteria


End Sub
 
G

Guest

The where condition should contain the name of the field that you want to
filter on in the form you open, equal to a value.
' For Number Field
DoCmd.OpenForm stdocname, , , "[FieldNameFromForm] = " & Me![ProjectNo]
' For Text Field
DoCmd.OpenForm stdocname, , , "[FieldNameFromForm] = '" & Me![ProjectNo] & "'"
' For Date Field
DoCmd.OpenForm stdocname, , , "[FieldNameFromForm] = #" & Me![ProjectNo] & "#"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top