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!

Adding new record in a subform

Status
Not open for further replies.

MrCroquet

Programmer
Dec 20, 2006
13
0
0
CA
In my wizard-generated "Order Entry" database (significantly modified over the years for our application), I am working on a macro that will add a new record in the Orders form. So far, it is set to "OpenForm" where upon it opens the Orders form. At that point, I would like to use the menu item "Add record" but it doesn't appear in the list of available commands in the "RunCommand" action.

The main goal here is to add a new record in the Order Details subform within the Orders form. That record appends to the table named Order Details. Once the new record is added, it needs to have two fields filled in. The first is a selection from a look-up field in the underlying table then tab over 5 columns and add a dollar amount that shows up in a text box on the Orders form, named "Amount Due".

I've tried Opening the Orders form, GoToControl, Tab into the first subform field then try to GoToRecord > New and also RunCommand > Insert Row. Both result in an error stating that the table isn't open or the Insert Row is not available.

Any thoughts on how to get this to work? (Access 2000)

PS - The entire purpose of the macro is to print an report (customer invoice), revise the payment amount, add a new line to the order details to account for the revised payment amount and print a second report (our invoice). This is needed when an order is processed in US$ and converted (for the credit card deposit) to Cdn $.
 
Hi

Check the syntax of the OpenForm

DoCmd.OpenForm MyForm, , , , acFormAdd

will open the form MyForm and automatically move it to a new record.




Hope this helps!

Regards

BuilderSpec
 
Thanks for the reply. I suspect you are considering this as a VBA event procedure. It is being done as a Macro. Here's the picture that may help clarify what's going on.

Residing in the "Orders" form is the "Order Details subform". The goal is to add a record to this subform that, in turn, appends to the "Order Details" table with the corresponding order number. Every action I try to accomplish this ends up with the same error --> "XXX is not open" with XXX being the subform, or table that I am calling to add the record to.

If you run the standard MS Access database creation wizard, you will see the database structure that I am essentially working with.
 
If all is ok, the order subform will show a new record (*) ready for use. Check if the subform property 'Allow Additions' is set to 'Yes'

Pampers [afro]
Keeping it simple can be complicated
 
Thanks Pampers

Unfortunately, the subform property was already set to "Allow for Additions".

I'm still trying different things but it's a busy time of season to be tinkering with code when Santa is about to arrive.
 
Yep, definetly not a good time, but maybe this helps (or not)...

Make sure that the underlying recordsource of the subform is updatable. Open the source and look at the record navigator... If the the new record sign is enabled (*), the recordsource is updatable, hence the subform is updatable, and, vice versa (if it is not enabled, then not updatable and so on).

Pampers [afro]
Keeping it simple can be complicated
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top