Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying a record in the original data entry form

Status
Not open for further replies.

7Oclock

Programmer
Mar 9, 2005
12
0
0
US
I would like to view a table in datasheet view, select a record and then view it in the original data entry form. How do I do this?
 
create a form that contains the recordsource that you want to display, add the required fields to the detail section (ensure that you include one that has a key field(s) that identify the record), then add code similar to the following, to each control that you want the user to be able to click in (I'd use double-click) which will open your Data entry form and send a value to the OpenArgs property of the Form.

DoCmd.OpenForm "DataForm", , , , ,ctlNameWithAKeyFldInIt
DoCmd.Close acForm, Me.Name


Then in your Data Entry form add code similar to the Form's On Load Event, which searches the recordset for the data and moves to the correct record.

Private Sub Form_Load()
If Me.OpenArgs <> "" Then
With Me.RecordsetClone
'this expects a numeric value, if yours is Text
'be sure to add delimiters
.FindFirst "TheKeyFieldName = " & Me.OpenArgs
If Not .NoMatch Then
Me.Bookmark = Me.RecordsetClone.Bookmark
End If
End With
End If
End Sub

To open the form that you want to view in Datasheet, you do that in the OpenForm Action

DoCmd.OpenForm "YourFormName", acFormDS

PaulF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top