Solved Button on Popup Form To Open Same Form But With New Record (1 Viewer)

LGDGlen

Member
Local time
Today, 18:11
Joined
Jun 29, 2021
Messages
229
I have a pop up form that displays delivered products. This form has a button on it that allows the user to re-deliver some of the product which has been rejected:

1629971564295.png


The user needs to select the product they wish to redeliver and then press the "Reject Product" button.
1629971876804.png


This will then open a NEW blank delivery form with the selected product details so the user can deliver the rejected product to a new client.

The problem i'm having is the VBA to open the form:

DoCmd.OpenForm "form-Delivery", , , , acFormAdd, , argumentsString

Does nothing. I am a bit confused by this. Do i need to effectively close the form in the VBA for the button press to open it again?

Hope this makes sense. Basically the upshot is i want to open the same popup form but with a blank record.

Thanks in advance

Glen
 

LanaR

Member
Local time
Tomorrow, 05:11
Joined
May 20, 2021
Messages
113
If the form is already open, then you will see nothing happen. It sounds like what you really want to do is create a new record partially populated with the items rejected from the current record?
 

LGDGlen

Member
Local time
Today, 18:11
Joined
Jun 29, 2021
Messages
229
@LanaR thanks for the response, and whilst you might have described the solution i'm not entirely sure what you mean. at the moment i can create NEW deliveries and all that works fine, just need to understand if i should close the form before the "openform" VBA line to get the process to work.

alternatively do i need to make a copy of this form to use in this specific circumstance (this really isn't what i want to do but will if i have to)
 

LanaR

Member
Local time
Tomorrow, 05:11
Joined
May 20, 2021
Messages
113
  1. You can not (re)open a form that is already open
  2. If product has been delivered to a client, that record (movement) is still valid, as the delivery did take place
  3. Given the above, the rejection should therefore be taken as a new (record) movement. It is going to a new destination, isn't it?
  4. It appears that you are using a checkbox to denote rejected product? If so you should be able to use that in an append query to partially create your new record.
  5. Will your client always reject a whole product line, or are there occasions when they might reject only a portion?
 

LanaR

Member
Local time
Tomorrow, 05:11
Joined
May 20, 2021
Messages
113
You might find this Course a valuable investment (especially if you can get it whilst it's on sale), as if memory serves me correctly, I think it does address similar scenarios to what you are trying to do.

I worked through it earlier this year and found it really useful in taking my coding to the next level.
 

LGDGlen

Member
Local time
Today, 18:11
Joined
Jun 29, 2021
Messages
229
the deliveries are built up of 2 tables:

Delivery information - static data that covers all products
Product information - 1 or many products delivered to a client

When a client rejects product we can deliver it to a second client (usually a market) so we create entirely new sets of static and product information.

The static information will be completely different, and needs to be in place to link the new product information that uses the delivered product information, but may change prices etc, the only thing that really will be the same will be the product description.

When the delivery form opens it can receive:
  • no arguments - in this instance it is being opened on a specific delivery and will display the delivery information based on the delivery ID
  • products to deliver - this details the initial products to delivery and creates a new record with products
  • delivery ID of the rejected delivery and product IDs of those products which have been rejected - this will create a new delivery and the new record will not have any of the current records details as the delivery will be completely different. Once the delivery details are created the "Product" records selected will be attached to this new record. the products are a separate table and multiple records and are linked to the current delivery.

the first 2 work fine its the scenario of creating a rejection delivery that i need to understand, i'll take a look at the course though
 
Last edited:

LanaR

Member
Local time
Tomorrow, 05:11
Joined
May 20, 2021
Messages
113
Are you able to post an anonymised version of your DB with some sample data?
 

LGDGlen

Member
Local time
Today, 18:11
Joined
Jun 29, 2021
Messages
229
may take a while have 1000s of records of test data across 26 tables and all of it has been imported from a live spreadsheet so trying to anonymise it might be tricky, i will try though

honestly i am pretty good with doing the stuff if people explain it, i have had the database reviewed by someone who has 20+ years DB experience and they're view was that other than a few naming convention quirks its pretty solid, this was prior to adding the rejection functionality mind you

its more a case of just an understanding of popup forms and how to re-open the same form on a new record from within the form, so to speak, if that can be explained as "yeah just close the form prior to opening with the new record by adding a bit of VBA to do X" or something along those lines i can take it from there, its more just a pointer in the right direction i need as this particular specific issue stumped me initially.

hope that makes sense, appreciate your assistance and time
 

LanaR

Member
Local time
Tomorrow, 05:11
Joined
May 20, 2021
Messages
113
Sounds like it is going to be a lot of work, so hold fire.

Opening and closing forms and maintaining focus on specific record(s) sounds was covered very well in the course I linked to.

When I click the link, the course is being offered at AUD 19.99 down from AUD 124.99 If you are seeing similar, then I would snap it up. It's the sort of thing you can work through at your leisure, and I think it should give you some pointers on solving your current problem.
 

LGDGlen

Member
Local time
Today, 18:11
Joined
Jun 29, 2021
Messages
229
i think i am probably not explaining things well enough so i will add, i do not need to retain focus on a specific record as i am creating new ones and passing details of things i need to know as arguments to the form open call as i don't need to know anything about the record i'm clicking the button on as all of the information on that record is irrelevant to the new one
 

LanaR

Member
Local time
Tomorrow, 05:11
Joined
May 20, 2021
Messages
113
If, as I surmised earlier, you are flagging returns using a checkbox. I think you should be able to pick those up and using an append query to partially create your new record and simply go to that record in the form you already have open, so you can complete it.
 

LGDGlen

Member
Local time
Today, 18:11
Joined
Jun 29, 2021
Messages
229
as an update:

DoCmd.Close acForm, "form-Delivery"
DoCmd.OpenForm "form-Delivery", , , , acFormAdd, , argumentsString

works and achieves what i want

the flagging of returns is just indicating which of the associated product records linked to the delivery will be used in the new delivery, their details are NOT part of the delivery form as such which will be completely new information. They will also only be used to gather some product information details to be used once the delivery to the new client has been documented.

Therefore the steps are:
  1. Create initial delivery
    1. Open up delivery form and create delivery static information
    2. Add products to delivery that will be sent to client
  2. At some point after the products have been delivered the client rejects some and lets us know
  3. User goes to the specific delivery and selects products listed that the client has rejected
  4. User clicks on reject product button
    1. This notes which products have been selected
    2. This opens a NEW blank delivery form for the user to enter the new client details into
    3. Once this form is saved the selected products will be added automatically with no price or amount details
      1. User enters new prices and amounts that will be delivered to new client
The process works once i close the original form (line 4.2) and open a new one, so it really was as simple as closing the currently opened delivery form before attempting to open the new one and all the other bits and pieces fall into place
 

LGDGlen

Member
Local time
Today, 18:11
Joined
Jun 29, 2021
Messages
229
@LanaR i will still take a look at the course though as i am sure there is tons of useful stuff on it and if it is discounted i will certainly put it to my boss as something that i would benefit from and see if they will fund it
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 02:11
Joined
May 7, 2009
Messages
19,169
you can re-open a form without first closing it?
 

Attachments

  • reDeliver.accdb
    604 KB · Views: 381

LGDGlen

Member
Local time
Today, 18:11
Joined
Jun 29, 2021
Messages
229
@arnelgp that is very interesting thank you. i've tested it out and its pretty much exactly what i want to do, it might even mean me re-looking at the ways in which i'm passing data around etc because right now the arguments to open form are quite limiting but if i create the new form the way your example shows i can just write the arguments directly to the hidden fields on it bypassing the building or an arguments string and then parsing said string on the form open

thank you, given me a lot to think about but in a very good way, much appreciated
 

Users who are viewing this thread

Top Bottom