Are you displaying a form to create a new person or display an
existing record? If existing, you should be able to create a link from
the record that you use to get the person's name and append the
person_id as an argument:

allpeople = db().select(db.person.ALL)
links = [A(row.firstname + " " + row.lastname,_href=URL
(r=request,f=show,args=[row.id])) for row in allpeople]

...then get it back with this query:

record=db(db.person.id==request.args[0])\
          .select(orderby=db.person.last_name) [0]

The id is record.id

If you're creating a new person, then db.person.insert(name="Rick
James") will return the id.

Hope that helps.

On Aug 24, 11:02 pm, jayvandal <jayvan...@gmail.com> wrote:
> I tried to get the person_id when I got a last name found, but I could
> not find a way to get the person_id with this code,
> Jim
>
> On Aug 24, 9:34 pm, "mr.freeze" <nat...@freezable.com> wrote:
>
> > It's always best to identify a unique record by id.  Unless you
> > intentionally want to update all persons with the same last name, I
> > would use person_id.
>
> > On Aug 24, 9:37 pm, jayvandal <jayvan...@gmail.com> wrote:
>
> > > HI,
> > > I tried this code
> > > =================================================
> > > records=db(db.person.last_name==request.vars.last_name)\
> > >           .select(orderby=db.person.last_name)
> > > ===================================================
> > > i see that this will find by last name or partial last name.
>
> > > I tried to get the person_id and use it to find all the events for
> > > that person and then display the event records.
>
> > > Can I do this or should I  do this??
> > > Thanks
> > > Jim- Hide quoted text -
>
> > - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to