Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 16th, 2003, 08:04 AM
Authorized User
 
Join Date: Jun 2003
Location: Swansea, , United Kingdom.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default setting subform to new record

I have a subform for storing patient data that is linked to the master form by the patient identifier number. The subform is deseigned to record investigation results indexed by patient number and date. How can I automatically move to a new record in this subform each time it has the focus? I have tried using a go to record macro with new record set but each time get an error "form not open"
Help please!!
Thanks

 
Old September 16th, 2003, 08:15 AM
IMO IMO is offline
Registered User
 
Join Date: Sep 2003
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In design view of your subform, select one of the fields and goto properties. In the Double Click event of that field put the following code...
Code:
Private Sub YourField_DblClick(Cancel As Integer)

DoCmd.GoToRecord , , acNewRec

End Sub
Now every time your main form is open and you Double Click on that field in the subform it will go to a new blank record.

HTH
IMO

 
Old September 17th, 2003, 02:14 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Melbourne, Vic, Australia.
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey skinny,

If you want the user to only be able to enter data, and not review it, set the DataEntry property to be true, but if you want them to be able to see the existing records until something happens (eg Field1 gets the focus) then change the dataentry property on that event for example:
Code:
Private Sub Field1_GotFocus()
Me.DataEntry = True
End Sub
Steven

I am a loud man with a very large hat. This means I am in charge
 
Old January 3rd, 2006, 04:57 AM
Registered User
 
Join Date: Dec 2005
Location: , , Zambia.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jonamukundu
Default

HOW ABOUT USING THIS CODE ON YOUR SUBFORM's ENTER EVENT


Private Sub YourSubForm_Enter()
' force the subform to always open in new record
DoCmd.GoToRecord , , acNewRec
End Sub

hope this helps
gimme feedback on jonamukundu@yahoo.com

 
Old January 3rd, 2006, 02:57 PM
Friend of Wrox
 
Join Date: Dec 2005
Location: , , .
Posts: 142
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Enter Design View on the subform you'd like to change. Open the Properties window, select the Detail item, go to the Event tab, push the "..." button next to "On Click" and enter the following line of code:

DoCmd.GoToRecord , , acNext

Add in any error handling code you'd like. Now whenever you click on the form itself you will move to the next record, but you will still be able to edit the text boxes. If you want to make the text boxes uneditable and have clicking on them advance to the next record too, simply add a transparent "Next Record" command button over the entire form.

Edit: Change acNext to acNewRec if you want it to go to a blank record, and use the first solution I listed instead of the 2nd.




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
Subform - Dynamically Setting mnoon Access 14 March 13th, 2005 07:33 PM
Creating a new record in a subform dlamarche Access 3 February 18th, 2005 12:33 AM
Subform only may contains 1 record Stanny Access 5 December 21st, 2004 11:17 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.