create a new record in a subform using a button on a form (1 Viewer)

laghetto

Registered User.
Local time
Yesterday, 19:15
Joined
Aug 20, 2011
Messages
27
i had a form with a button and a subform.
i need that pressing on the button a new record in the subform will be added.
if possible in the data field of subform i'd like to save the data of that event and in another field copy the value of a field of the main form.
if i press again the button it will create a new record with data and copied field.

marry christmas!

al
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 03:15
Joined
Jul 9, 2003
Messages
16,280
i had a form with a button and a subform.
i need that pressing on the button a new record in the subform will be added.
if possible in the data field of subform i'd like to save the data of that event and in another field copy the value of a field of the main form.
if i press again the button it will create a new record with data and copied field.

If you mean that you have a main form which contains the master record, the parent record, and your subform contains a child record then no it’s not possible.

It’s not possible because you can’t have a child without a parent.

I have noticed this scenario seems to be a reoccurring problem and I have been giving it some thought.

From my own experience a situation where you might want to do this would be when you are creating a quote for an unknown customer, typical scenario, someone rings you up for a price, you ask for their name, they won’t give it to you! They say they just want a price, now the system you have set up requires the parent record to be filled, in other words it is expecting a customer name.

You find that you cannot add a child record without this parent record, but you don’t know the identity of the customer, so what do you do?

One solution is to have a “special customer” in your system usually called “cash customer” or if you wanted you could call it “quotation” now once you have completed the quotation and the customer agrees to the price and wants to arrange delivery, then you just go back to the main record and change it from a “cash customer” to the actual customer who has placed the order.
 

laghetto

Registered User.
Local time
Yesterday, 19:15
Joined
Aug 20, 2011
Messages
27
hi!
i'm not sure to have understood.
or that my explanation was ok.
so i post my file.

thanx anyway
 

Attachments

  • stuffi_o_matic.zip
    24.2 KB · Views: 508

harmankardon

Registered User.
Local time
Yesterday, 23:15
Joined
Aug 8, 2011
Messages
71
I'm not sure I understand the request. I've looked at the access mbd that you posted but I'm still unclear as to what you are requesting.

Do you just want to add a new record to your subform and insert some data into this new record using the parent record as the source?
 

laghetto

Registered User.
Local time
Yesterday, 19:15
Joined
Aug 20, 2011
Messages
27
hi,
i need that clicking on de button, in the main form, a new record will be added in the small one and if possible in the date field of this (always the second) it will saved the date of the event.

bye
 

harmankardon

Registered User.
Local time
Yesterday, 23:15
Joined
Aug 8, 2011
Messages
71
Where will users input the data that goes into the smaller form? Your subform already has the Add New row at the bottom, if users enter data in there it will create a new record.
 

laghetto

Registered User.
Local time
Yesterday, 19:15
Joined
Aug 20, 2011
Messages
27
I have uploaded a new db with some explanations, i hoper i could be useful.


have a nice day
 

Attachments

  • stuffi_o_matic_v1.zip
    24.7 KB · Views: 798

harmankardon

Registered User.
Local time
Yesterday, 23:15
Joined
Aug 8, 2011
Messages
71
So you just need to add a record to the subform using a button on the main form?

Make a button and call it say, btnNew then in the On Click event for the button, use the following code as a template:

Code:
    With Me.M_tab_registrazioni.Form.RecordsetClone
         .AddNew
              !data_registrazione = Now()
              !ID_promemoria = Me.ID_promemoria
         .Update
    End With

Try that and let me know if that's is sort of what you are looking for.
 

laghetto

Registered User.
Local time
Yesterday, 19:15
Joined
Aug 20, 2011
Messages
27
it works!!!!!!!!!
great great great!
thank you fot your help and patience!
sorry for make you lose time before to post the last file.

i wish you have a wonderful christmas!
 

Ashisht76

Member
Local time
Today, 07:45
Joined
Jan 31, 2022
Messages
44
So you just need to add a record to the subform using a button on the main form?

Make a button and call it say, btnNew then in the On Click event for the button, use the following code as a template:

Code:
    With Me.M_tab_registrazioni.Form.RecordsetClone
         .AddNew
              !data_registrazione = Now()
              !ID_promemoria = Me.ID_promemoria
         .Update
    End With

Try that and let me know if that's is sort of what you are looking for.
Thaks a ton! even after 11 years your still best as no one else could give me precise reply in my question, please find the link.

 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 03:15
Joined
Jul 9, 2003
Messages
16,280
Thaks a ton! even after 11 years your still best as no one else could give me precise reply in my question, please find the link

What a dick head!

Russian
Какая голова хуя!

Not a good translation, but near enough for me....
 

Users who are viewing this thread

Top Bottom