Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 16th, 2005, 07:44 PM
Authorized User
 
Join Date: Feb 2005
Location: Frankston South, Victoria, Australia.
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default Creating a new record in a subform

Hi. I ran into a weird difficulty the other day. I was trying to open a form from another form and move to the new record IN THE SUBFORM! I was never able to do it!

I've been programming forms for a few years with VBA but I never encountered this one! I am opening the form from a command button in another form and it is supposed to move to the new record in the subform right away but (and it makes sense) it moves to the new record in the main form. When I try to refer to the subform after the OpenForm method I am always told that the form is not open thus I cannot move to the new record.

I solved my problem by making the subform's DataEntry property to True but I loose sight of the other records in the subform.

Any ideas anyone???

Daniel

Daniel
__________________
Daniel
Reply With Quote
  #2 (permalink)  
Old February 16th, 2005, 08:59 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Hi Daniel,

Private Sub Form_Load()
    Me.YourSubFormName.SetFocus
    DoCmd.RunCommand acCmdRecordsGoToNew
End Sub


HTH,

Bob

Reply With Quote
  #3 (permalink)  
Old February 17th, 2005, 10:59 PM
Authorized User
 
Join Date: Feb 2005
Location: Frankston South, Victoria, Australia.
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Humm Bob, thank you very much for the simplest answer I could dream of. I had not even think about the RunCommand method. Funny coz I do used it to save a record and other useful thing.

I really appreciate that you spent a few minutes answering this one.

Daniel

Here's the somple code that I can now use:

Private Sub Form_Load()
    If Me.OpenArgs = "NewEntry" Then
        Me.sforTesting.SetFocus
        DoCmd.RunCommand acCmdRecordsGoToNew
        DoCmd.GoToControl "FinDetailMontant"
    End If
End Sub



Daniel
Reply With Quote
  #4 (permalink)  
Old February 18th, 2005, 12:33 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Glad to help Daniel. Can't count the number I've times I've spent hours and lines of code on a problem, only to have someone hand me the saving two-liner.

Best,

Bob :)

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting a record from a subform captainlove Access VBA 3 May 1st, 2008 11:38 AM
How do I delete a record from a subform captainlove SQL Server ASP 1 April 29th, 2008 12:01 AM
setting subform to new record skinny Access 4 January 3rd, 2006 02:57 PM
selecting only one primary record in a subform Richard Lally Access 2 April 1st, 2005 10:20 AM
Subform only may contains 1 record Stanny Access 5 December 21st, 2004 11:17 AM



All times are GMT -4. The time now is 05:08 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.