Open form, go to record

brharrii

Registered User.
Local time
Yesterday, 22:47
Joined
May 15, 2012
Messages
272
I'm using the following code to allow the user to pick a record from a continuous form and edit it in a new window. For some reason my where condition isn't working properly as the edit form always opens to the first record instead of the record associated with the "Edit" button that was pressed.

Can anyone tell me what I've done wrong?

Thanks!

Code:
Private Sub lblEdit_Click()
    DoCmd.OpenForm "frmEditPlants", acNormal, , "[PlantID] = " & Me.PlantID, acFormEdit, acDialog
    
End Sub
 
Is PlantID numeric or text.
If you place a breakpoint at the end and then hover the mouse over Me.PlantID, what value is shown.
 
it is Numeric. It's an auto incrementing primary key for tblPlants.

The value that shows when I place a breakpoint, regardless of which record I've clicked is 1.

Thanks again!
 
Strange... I wonder why. I usually use Labels instead of buttons because I feel like I can control their appearance a little more easily. But in this case especially a button will work just as well.


Thank you for your help :)
 

Users who are viewing this thread

Back
Top Bottom