My Assistant
![]() ![]() |
|
|
May 13 2008, 04:11 PM
Post
#1
|
|
|
UtterAccess Guru Posts: 820 From: Tennessee, USA |
I feel really dumb, but I cannot remember how to set a Form to open to a "new record", instead
of the first record. I searched the archives here (and in Microsofts website) but I cannot seem to find it. Isn't it somewhere on the Property Sheet? Surely I don't have to write code to make this happen? Thanks. Al T. |
|
|
|
May 13 2008, 04:15 PM
Post
#2
|
|
|
UtterAccess Editor Posts: 4,786 From: Omaha, NE USA |
Set Data Entry property to yes.
HTH cynthia |
|
|
|
May 13 2008, 04:27 PM
Post
#3
|
|
|
UtterAccess Guru Posts: 820 From: Tennessee, USA |
Well, Yes and No. My "Data Entry" property was set to 'No', however, setting it to 'Yes' didn't have any effect. Thank you Cynthia, but what do I need to try next?
Al T. |
|
|
|
May 13 2008, 04:37 PM
Post
#4
|
|
|
UtterAccess Addict Posts: 215 From: New York |
On "On Open" event of your form,
enter this DoCmd.GoToRecord acDataForm, Me.Name, acNewRec |
|
|
|
May 13 2008, 05:09 PM
Post
#5
|
|
|
UtterAccess Guru Posts: 820 From: Tennessee, USA |
Keep getting errors. It wants me to fix something with the code. I've tried the following, and nothing works:
DoCmd.GoToRecord acDataForm, Me.Main, acNewRec DoCmd.GoToRecord acDataForm, "Me.Main", acNewRec DoCmd.GoToRecord acDataForm, ["Me.Main"], acNewRec DoCmd.GoToRecord acDataForm, Main, acNewRec DoCmd.GoToRecord acDataForm, "Main", acNewRec DoCmd.GoToRecord acDataForm, ["Main"], acNewRec The error is coming up with the Main part of it (the name of the form) I was trying to avoid this (coding), but I'll do it if I can get it to work... Al T. |
|
|
|
May 13 2008, 05:23 PM
Post
#6
|
|
|
UtterAccess Editor Posts: 4,786 From: Omaha, NE USA |
how about acCmdRecordsGoToNew on Open Event?
|
|
|
|
May 13 2008, 05:38 PM
Post
#7
|
|
|
UtterAccess Guru Posts: 820 From: Tennessee, USA |
I've never seen that syntax before, I applied it in the Property Sheet, error. Then I tried it as an "Event"
(VB Editor --- On Open event) and it also returned an error. I'm pretty sure that I've used code similar to this: DoCmd.GoToRecord acDataForm, "Main", acNewRec ...and it has worked. So I dunno. I've just got to keep probing. It's probably a 'conflicting' event. I'm using a "Tabbed" form, and even changing around the 'Page Order' doesn't have a bearing on it. Al T. Edited by: mraetrudeaujr on Tue May 13 18:42:37 EDT 2008. |
|
|
|
May 13 2008, 05:45 PM
Post
#8
|
|
|
UtterAccess VIP Posts: 6,898 From: Earth... |
Al T.
Why dosen't this work: DoCmd.GoToRecord , , acNewRec |
|
|
|
May 13 2008, 05:52 PM
Post
#9
|
|
|
Utterly Yorkshire and Forum/Wiki Editor Posts: 15,885 From: Devon UK |
As Cynthia originally replied, setting the Data Entry property of the form to Yes should open the form at a new record......you must have some code somewhere that's over riding that setting...?
|
|
|
|
May 13 2008, 05:56 PM
Post
#10
|
|
|
Retired Moderator Posts: 37,716 From: The San Francisco Bay Area |
I agree with Alan as Cynthia's code should work. Something else is going on with your form and you need to figure out what it is and then you should be good to go...
My 3 cents worth.. Jack |
|
|
|
May 13 2008, 06:05 PM
Post
#11
|
|
|
UtterAccess Guru Posts: 820 From: Tennessee, USA |
Alan, yes I remember doing that for another database, but when it didn't work, I decided to go with the code, when it didn't work...yes, I figured out WHAT was overriding that snippet of code.
But after all of these efforts, going to a new record IS NOT what I need (IMG:http://www.utteraccess.com/forum/style_emoticons/default/crazy.gif) It (obviously) is just adding new "blank" records every time I open the form. Actually, I just need the Database to start with a 'blank' form --- I'll use my search box to find the record I want. So what next? Do I need a "dummy" record (blank), and direct the On Open event to GoTo it? ============== Updated: Unless someone can give me a 'workaround', I think that it's safer to just 'pick' a record (like mine (IMG:http://www.utteraccess.com/forum/style_emoticons/default/thumbup.gif) ) and have the databases' "On Open" event 'GoTo' it. I've already tried it, and it works. How could I adjust the above code that I'm referring to CODE DoCmd.GoToRecord acDataForm, "Main", acGoTo, 59
....to go to the "LAST" record that I was at when I closed the form? The 'GoTo' code refers only to; "Previous, Next, First, Last, Go To, or New". BTW: for all of the other contributors here; I originally had the following code on the Form's "On Load" event. That is what was 'overriding' any and every suggestion that I was trying: CODE Private Sub Form_Load()
'Me.OrderBy = "[StarNo]" 'Me.OrderByOn = True End Sub Thanks. Al T. Edited by: mraetrudeaujr on Tue May 13 19:15:55 EDT 2008. Edited by: mraetrudeaujr on Tue May 13 19:31:26 EDT 2008. |
|
|
|
May 13 2008, 06:55 PM
Post
#12
|
|
|
Utterly Yorkshire and Forum/Wiki Editor Posts: 15,885 From: Devon UK |
I'm definitely getting a bit confused now (IMG:http://www.utteraccess.com/forum/style_emoticons/default/laugh.gif)
If you want to open the form at a new record, but still be able to navigate thru any other records then leave the Data Entry property set to No and just use DoCmd.GoToRecord , , acNewRec in the On Open event of the form |
|
|
|
May 13 2008, 07:03 PM
Post
#13
|
|
|
UtterAccess Guru Posts: 820 From: Tennessee, USA |
...and this will then NOT save these "New" (blank) records?
That is what was happening. In other words, if I opened the database to look for some information, and I did this ten times, WITHOUT saving anything...it wouldn't matter. The DB would still save these newly opened blank (generated by the 'On Open' code) records. I hope this explains it better. I was just trying to find a way to open the database without seeing the same record (persons name) over and over (IMG:http://www.utteraccess.com/forum/style_emoticons/default/dazed.gif) Al T. |
|
|
|
May 13 2008, 07:14 PM
Post
#14
|
|
|
Utterly Yorkshire and Forum/Wiki Editor Posts: 15,885 From: Devon UK |
Sorry - I'm still confused. Opening a form with
DoCmd.GoToRecord , , acNewRec WONT save a blank record if you just close the form without entering any data into the new record. If it is doing, then you've got something else going on somewhere.........? |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 23rd May 2013 - 11:41 PM |