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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open form on Current Record 1

Status
Not open for further replies.

hefly

Technical User
Feb 6, 2008
134
US
I need to open a form to edit and add records. I would like my form to show the data linked to current record field "LeaseID." The form currently opens on the last viewed record. Here is my code:

Code:
Option Compare Database

Private Sub Command189_Click()

End Sub

Private Sub Combo191_DblClick(Cancel As Integer)
'Event ON DOUBLECLICK
If IsNull(LessorID) Then
    DoCmd.OpenForm "frmLessors"
Else
    DoCmd.OpenForm "frmLessors", , , , , , LessorID
End If

End Sub

Thank you.

Hefly
 
IF the lessorID field is numeric, and IF the control holding that field is called LessorID, and IF the field in the underlying data source of frmLessors is also called LessorID, then change your code to the following in the last part of your if statement:

Docmd.OpenForm "frmLessors",,,"[LessorID] = " & me.LessorID

The first LessorID needs to be the field on frmlessons. The second one is the control name that's on the form you're starting from.

If LessorID is a string (not numeric) then the line should read:
Docmd.OpenForm "frmLessors",,,"[LessorID] = " & chr(34) & me.LessorID & chr(34)
 
Cindy K! Thank you so much for your explanation and the solution. It now works!!! :)))

Hefly
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top