Still having trouble with new record (1 Viewer)

Demetious

Registered User.
Local time
Today, 11:06
Joined
Sep 7, 2010
Messages
48
Folks,
I am trying to get a page on my form to open to a new record. I was given a couple of ways to do it, and looked a couple up myself with no luck. I have coded the event in the Forms OnLoad event. I have tried a Macro as well. The only way I can seem to make it work is to change Data Entry to yes which doesn't allow me to change other records. The page name is Item Information_Page and it is located on the Inventory Details form. Thank you for any help.
 

boblarson

Smeghead
Local time
Today, 08:06
Joined
Jan 12, 2001
Messages
32,059
What code did you use?

You should be able to use this:
Code:
If Not Me.NewRecord Then
   DoCmd.RunCommand acCmdRecordsAddNew
End If

And there are other ways as well.
 

boblarson

Smeghead
Local time
Today, 08:06
Joined
Jan 12, 2001
Messages
32,059
Oh, is this a subform?
 

vbaInet

AWF VIP
Local time
Today, 16:06
Joined
Jan 22, 2010
Messages
26,374
Were you given:

Docmd.Runcommand acCmdRecordsGoToNew

?

Is it on a single form you're trying to do this or on a subform?
 

Demetious

Registered User.
Local time
Today, 11:06
Joined
Sep 7, 2010
Messages
48
Were you given:

Docmd.Runcommand acCmdRecordsGoToNew

?

Is it on a single form you're trying to do this or on a subform?

I believe it is on a single form but it has multiple pages. My understanding of a subform is that it corresponds to data in other forms, that is not my case. I do however have three pages on the form with tabs for each page. Does that make sense? I have used the basic Inventory Template that came with MS 2007 and have added some more functionality to it.
 

vbaInet

AWF VIP
Local time
Today, 16:06
Joined
Jan 22, 2010
Messages
26,374
Can we see a stripped down version of your db?
 

vbaInet

AWF VIP
Local time
Today, 16:06
Joined
Jan 22, 2010
Messages
26,374
The actual db, but get rid of sensitive information leaving just some data to test with.
 

Demetious

Registered User.
Local time
Today, 11:06
Joined
Sep 7, 2010
Messages
48
Doh,
It's too big. Here are a couple screenshots to include the code I have for the form. I have tried the code in the OnCurrent as well as the OnLoad. Let me know if you need anything else please. Thank you for all your help.
 

Attachments

  • InventoryForm1.jpg
    InventoryForm1.jpg
    94.8 KB · Views: 83
  • InventoryForm_Design1.jpg
    InventoryForm_Design1.jpg
    102.7 KB · Views: 87

vbaInet

AWF VIP
Local time
Today, 16:06
Joined
Jan 22, 2010
Messages
26,374
What about:

Docmd.Runcommand acCmdRecordsGoToNew

try that.

And you put the code in the click event of a button.

If your main objective is to get the form to open to a new record when it loads then you can do it in the OpenForm method like this:

Code:
DoCmd.OpenForm "FormName", , , , acFormAdd
 

Demetious

Registered User.
Local time
Today, 11:06
Joined
Sep 7, 2010
Messages
48
My goal is to have the form, when opened, to open to a new record.

Private Sub Form_Load()
DoCmd.OpenForm "Inventory Details", , , , acFormAdd
End Sub

This is my code in the Form On Load event. I'm sure I am doing something stupid but I can't figure it out. Thanks again.
 

vbaInet

AWF VIP
Local time
Today, 16:06
Joined
Jan 22, 2010
Messages
26,374
You're putting the code in the wrong event and in the wrong form module.

How does the form get opened? Isn't it via a button? Or does an autoexec deal with this?
 

Demetious

Registered User.
Local time
Today, 11:06
Joined
Sep 7, 2010
Messages
48
The form opens automatically when I open my DB. If need be, I can change that back to open through the navigation window. My goal is to have only two forms available to Shipping/Recieving when I split my DB. One for inventory detials and one to add/remove inventory.
 

vbaInet

AWF VIP
Local time
Today, 16:06
Joined
Jan 22, 2010
Messages
26,374
Have you tried:

Docmd.Runcommand acCmdRecordsGoToNew

in the Load event of the form?

If that's not working for you then you need to use an autoexec macro which will cause your form to load when the db is first opened. In that macro you can choose or type in that acFormAdd option.
 

boblarson

Smeghead
Local time
Today, 08:06
Joined
Jan 12, 2001
Messages
32,059
What code did you use?

You should be able to use this:
Code:
If Not Me.NewRecord Then
   DoCmd.RunCommand acCmdRecordsAddNew
End If

And there are other ways as well.

I posted the wrong code. vbaInet has it right. It should be

DoCmd.RunCommand acCmdRecordsGoToNew (not AddNew).

 

vbaInet

AWF VIP
Local time
Today, 16:06
Joined
Jan 22, 2010
Messages
26,374
I posted the wrong code. vbaInet has it right. It should be

DoCmd.RunCommand acCmdRecordsGoToNew (not AddNew).

Hehe! We noticed but we didn't say a word.:)

I think you should propose that to Microsoft in their next release, sounds more plausible.
 

boblarson

Smeghead
Local time
Today, 08:06
Joined
Jan 12, 2001
Messages
32,059
My brain is currently a mess with what we're working on at work.
 

vbaInet

AWF VIP
Local time
Today, 16:06
Joined
Jan 22, 2010
Messages
26,374
Yes, I remember seeing a post where you mentioned you were very busy. Good luck with it!
 

Demetious

Registered User.
Local time
Today, 11:06
Joined
Sep 7, 2010
Messages
48
This is the entire code in the Form event Load

Private Sub Form_Load()
DoCmd.RunCommand acCmdRecordsGoToNew
End Sub

I open the DB and the form opens to Record 1. /shrug
I don't know VB code and I obviously suffer from a mild case of stupidity.
 

vbaInet

AWF VIP
Local time
Today, 16:06
Joined
Jan 22, 2010
Messages
26,374
There's something not just right there. I can't see why it wouldn't go to new. Is the ALLOW ADDITIONS property of the form set to Yes?
 

Users who are viewing this thread

Top Bottom