function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
NikolaMNikolaM 

How do I get an account lookup and then save the account in DB on a visualforce page?

I have a custom object and I have created a lookup through a button using a visual force page on that object but I could not save the account record in DB, how do I do that?

public with sharing class Lookup {
public Account t{get;set;}

public Lookup ()
{
   t =new Account();
   String tId = ApexPages.currentPage().getParameters(). get(‘id’);
   t = [Select name From Account Where Id =:tId];
  
}
 
public pagereference save(){

insert t;
return null;
}
}