Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open a clean form rather than #1 and then go to clean

Status
Not open for further replies.

kentwoodjean

Technical User
Oct 19, 2002
376
0
0
US
I know that this is probably very simple, but I can't seem to find my answer. Most often, when you open any of my forms, you open beginning with form #1. Now there may be 3000 forms, which means you have to hit the "create new rec" button to get to the back. What type of Event do I create to make this happen? Tried different events tied to form as opposed to a field, and none that I could see would work.
 
I have also been looking for an answer to it, if you figure it out elsewhere, could you post it for me? Thanks!
 
Try this, Open the form in Design mode, change the property "Data Entry" to Yes, save and close. Now when you open the form it will always be a new record.
 
This works for when you first open the form. However, I have 2 subforms, and on the outer form you can change which person you are selected, and it brings up the data in the subform related to those people. Whenever I change people, it still goes to the first in the column. Is there a way to force it to go to a new entry whenever the form changes?

Thanks!
 
or . . . . in the [blue]Click event[/blue] of the button, copy/paste the following code:
Code:
[blue]   If Not Me.NewRecord Then DoCmd.RunCommand acCmdRecordsGoToNew[/blue]

Calvin.gif
See Ya! . . . . . .
 
Yes, when you first open the form, it is a new form. I would still like to be able to go back to a form if necessary since it is necessary to put end dates on the forms once an assignment is completed. By changing the dataentry to Yes, I don't have the ability to navigate to a former record if I want to. Can I do that?
 
If you do what TheAceman1 said, you should still be able to navagate through all of the records.

I got it to work for the main form, but I can't figure out how to make it work for the subforms. My subform is called [Points Sheet Table - 1 per Date Subform] (I didn't name it!) In the afterUpdate of the combobox that changes students, I have


DoCmd.GoToRecord acDataForm, "[Points Sheet Table - 1 per Date Subform]", acNewRec

Which as far as I can tell should go to a new record in that form, and I think is pseudo equivalent to what Aceman is doing above. However, it gives me an error message saying the form isn't open. If I change the form name to the name of the parent form, then it works fine. Any thoughts?

Thanks!
 
How are ya timekeepr9 . . . . .

Bear in mind, a [blue]subform is a control[/blue] as far as the mainform is concerned. Therefore, [purple]the method your using is only good form single or main forms.[/purple]

The method I gave will work for subforms. You just have to bear it mind that [purple]it works for the form with the focus![/purple] So what you have to do is set the focus to the subform first:
Code:
[blue]Forms![purple][b]MainFormName[/b][/purple]![Points Sheet Table - 1 per Date Subform].SetFocus
If Not Me.NewRecord Then DoCmd.RunCommand acCmdRecordsGoToNew[/blue]

Calvin.gif
See Ya! . . . . . .
 
Awesome, that works except one problem. For some reason the if Not Me.NewRecord part doesn't seem to be doing it's job. If it is already on a new record, it throws an error. I cheatingly got around it be telling it to exit sub if it gets an error, but is there a proper way to do it?

Thanks for your help!
 
timekeepr9 . . . . .

Sorry about that . . . should be:
Code:
[blue]   If Not Forms![purple][b]MainFormName[/b][/purple]![purple][b]subFormName[/b][/purple].Form.NewRecord Then 
      DoCmd.RunCommand acCmdRecordsGoToNew
   End If[/blue]

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top