Edit a selected record in subform using form

joshi868b

Registered User.
Local time
Today, 17:12
Joined
Jul 26, 2016
Messages
10
I have a subform which shows the list of record .primary key is not assigned.i want to select a record from subform and want to click on a button called edit.it should open the form with the selected details.thanks in advance . suppose the subform name is" portdetails subform" and filed are l2 ip address, vlan ,mac address,name ,ser no,dn no,.can i attach the database here in this forum .
 
best to put AutoNumber field in the underlying table of your subform. so you can refer to it on the clicke event of edit button.

private sub editButton_click()
docmd.openform "formname", acNormal,,"[autonumberfield]=" & me.[autonumberfield]
end sub
 
I believe you need at least 10 posts before you can upload files. Is the subform in continuous view or data sheet view? Why don't you have a Primary Key (PK) for this table?
 
DEAR RURAL GUY,
IT IS A DATA SHEET VIEW. And there is not any suitable field to choose a s primary key
 
Which is why "arnelgp" recommended adding an AutoNumber field (PK) to the table. Those PKs can come in real handy sometimes and all it costs you is a little disk space. Is there anything in that table record that makes it unique?
 
this is table of different field like mac address (unique). but all the records does not have the mac address some have blank filed .
 
Thanks jdraw! See, I learn something new every day. :)
 
IN THE ATTACHED DATABASE WHEN I OPEN THE FORM "FORM1" AND SELECT ANY RECORD FROM THE SUBFORM AND CLICK THE EDIT BUTTON. IT SHOULD OPEN THE FORM "editfrm" WITH THE SELECTED RECORD SO THAT FURTHER I CAN UPDATE THE DETAILS.
 

Attachments

I'll be honest, using ALL CAPS is called SHOUTING on the internet. Thanks.
 
Thanks! It looks pretty straight forward to fix. Give me a minute.
 
Change the procedure code under the Edit button to:
Code:
Private Sub Command15_Click()
     DoCmd.OpenForm "editfrm", , , "id =" & [Table1 subform].Form.ID
End Sub
 
The Sample submitted has an AutoNumber PK field. Pretty easy to solve.
 
It Is not working. can u attach the sample with solution please
 

Users who are viewing this thread

Back
Top Bottom