Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Open database from child form

Geek News

Open database from child form
John F. 12/14/2008 3:27:01 AM
Hi,
I have a subform and a button that I want to click to enter a new record on
the subform. I've tried the following but it doesn't do anything. When I
click the 'Add New Record' on the bar at the bottom of the subform, it opens
to a new record; this is the action that I want to replicate on my button.
How do I d this?

This is the code that doesn't work:

Private Sub btnAddNewAdmission_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDb()
Set rs = db.OpenRecordset("tblAdmitDateLocation")

rs.AddNew
rs.Bookmark = rs.LastModified


Thanks in adavance!

John Fowler.
Re: Open database from child form
Tom van Stiphout <tom7744.no.spam[ at ]cox.net> 12/14/2008 3:51:06 AM
On Sat, 13 Dec 2008 19:27:01 -0800, John F.
<JohnF[ at ]discussions.microsoft.com> wrote:

Replace all of that with:
RunCommand acCmdRecordsGoToNew

-Tom.
Microsoft Access MVP


[Quoted Text]
>Hi,
>I have a subform and a button that I want to click to enter a new record on
>the subform. I've tried the following but it doesn't do anything. When I
>click the 'Add New Record' on the bar at the bottom of the subform, it opens
>to a new record; this is the action that I want to replicate on my button.
>How do I d this?
>
>This is the code that doesn't work:
>
>Private Sub btnAddNewAdmission_Click()
> Dim db As DAO.Database
> Dim rs As DAO.Recordset
>
> Set db = CurrentDb()
> Set rs = db.OpenRecordset("tblAdmitDateLocation")
>
> rs.AddNew
> rs.Bookmark = rs.LastModified
>
>
>Thanks in adavance!
>
>John Fowler.
Re: Open database from child form
John F. 12/15/2008 1:12:01 AM
Thanks, that works great.

john.

"Tom van Stiphout" wrote:

[Quoted Text]
> On Sat, 13 Dec 2008 19:27:01 -0800, John F.
> <JohnF[ at ]discussions.microsoft.com> wrote:
>
> Replace all of that with:
> RunCommand acCmdRecordsGoToNew
>
> -Tom.
> Microsoft Access MVP
>
>
> >Hi,
> >I have a subform and a button that I want to click to enter a new record on
> >the subform. I've tried the following but it doesn't do anything. When I
> >click the 'Add New Record' on the bar at the bottom of the subform, it opens
> >to a new record; this is the action that I want to replicate on my button.
> >How do I d this?
> >
> >This is the code that doesn't work:
> >
> >Private Sub btnAddNewAdmission_Click()
> > Dim db As DAO.Database
> > Dim rs As DAO.Recordset
> >
> > Set db = CurrentDb()
> > Set rs = db.OpenRecordset("tblAdmitDateLocation")
> >
> > rs.AddNew
> > rs.Bookmark = rs.LastModified
> >
> >
> >Thanks in adavance!
> >
> >John Fowler.
>

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net