Copying Field Data from Form A to B

SwmpDnky

New member
Local time
Today, 20:09
Joined
Jan 22, 2022
Messages
9
Hi.. I have created a sweet Access Application but have some fundamental issues which i hope are easily fixed.

I have a Form Called "JobInfo" and a second called "ProductInfo" they are linked by a JobID field (which exists as an AutoNumber in "JobInfo").

I have created a Button in "JobInfo" which Opens a New Record in "ProductInfo" but i would like the JobID which has just been created on the previous Form to be carried across to pull the data through..... is this an easy thing to do? At present if you type the appropriate number it pulls the data through but i dont want to rely on the User remembering and entering the correct Number.

Thanks in advance for any help
 
There are different ways to accomplish this task (as there are for many things in Access).
Probably the most straightforward is to create a main form bound to JobInfo and a sub form bound to ProductInfo. Instead of opening ProductInfo as a second form, embed it in a subform control IN the JobInfo form. Use the Master/Child Linking fields of the subform control to link them on JobID.
 
Thanks
There are different ways to accomplish this task (as there are for many things in Access).
Probably the most straightforward is to create a main form bound to JobInfo and a sub form bound to ProductInfo. Instead of opening ProductInfo as a second form, embed it in a subform control IN the JobInfo form. Use the Master/Child Linking fields of the subform control to link them on JobID.
Thanks for your reply.. i think i may have gone too deep in developing the database to now do this.. is there anyone that can create this without adding additional forms.. happy to pay for development time etc..
 
Does the Button in JobInfo open the ProductInfo form or is the ProductInfo form already open? Are you creating a single record in the ProductInfo form and then closing? You probably want to look at the OpenArgs argument of the DOCMD.OpenForm method. Then you can pass the JobID to the ProdInfo form. Or you can simply set the value of the JobId in the ProdInfo form from the JobInfo form after opening the ProdInfo form.

It may be as simple as the calling form setting the value in the called (prodInfo) form.
Docmd.Openform "frmProdInfo"
forms("frmProdInfo").JobID = Me.JobID
 
Does the Button in JobInfo open the ProductInfo form or is the ProductInfo form already open? Are you creating a single record in the ProductInfo form and then closing? You probably want to look at the OpenArgs argument of the DOCMD.OpenForm method. Then you can pass the JobID to the ProdInfo form. Or you can simply set the value of the JobId in the ProdInfo form from the JobInfo form after opening the ProdInfo form.

It may be as simple as the calling form setting the value in the called (prodInfo) form.
Docmd.Openform "frmProdInfo"
forms("frmProdInfo").JobID = Me.JobID
Thanks for coming back to me details in the next post below..
 

Attachments

  • SS.jpg
    SS.jpg
    79.7 KB · Views: 280
  • SS1.jpg
    SS1.jpg
    81.5 KB · Views: 238
  • SS2.jpg
    SS2.jpg
    112.4 KB · Views: 271
So the 1st SS shows the JobInfo with the JobID AutoNumber... When you click the Button in SS1 it Opens the Form Shown in SS2 but leaves the JobInfo Tab open.. its the JobID shown in SS2 that i would like to completed automatically by essentially copying and pasting from the previous form (if that makes sense) in the example above i manually typed it in..
 
Is that button only for adding a new drawing or what do you want to happen if a drawing already exists?
There is really no reason for openArgs unless you open the form ACDIALOG. That requires extra steps. Simply set the jobID from the controlling form. If you want to "Add New" then specify this in the openform method

DoCmd.OpenForm "sashInfo", , , , acFormAdd
forms("sashInfo").jobid = me.jobID

But if you do above it will only allow you to add a new drawing and not view the existing drawing. Then you might want to have two buttons
View Drawings and Add New Drawing.

You can combine it where it will open to any existing drawings, but will default to the JobID for subsequent.
 
If it was me, and drawings are something you routinely look at then you have plenty of real estate. I would just have a tab control. Tab 1 would be job info, tab 2 would be drawings. You would not have to build new forms, just drag the drawing form as a subform on to the second tab. This then requires no code and avoids the popping open and closing of forms.
 
My idea was to use that particular button to add a new drawing only, and create a second button for viewing previously created drawings..

So that my simple brain can understand this..

1. I should edit the Macro on that button to Close the "JobInfo" Form first and then Open the ProductInfo form. (as this as you say is better practice)
2. Can I then use VBA on the "ProductInfo" to insert the value of JobID using..... forms("sashInfo").jobid = me.jobID
 
You can
Open the drawing form
Set the JobID
Close the Job form.

The only problem with that is now you have to code it to return to the Jobinfo for that job. You can add that additional code or just leave the Job form open. You can make your sashInfo form "Pop Up" and "Modal". Then when it opens the only thing you really can do is close it. You cannot move to other forms. Modal means that you cannot move focus off of that form without closing it.
 
Thank you very much for your kind help.. being honest i didn't know that OpenArgs existed!. I will save a few copies of the File and then explore your kind suggestions! Thanks again
 
See demo.
In this design it opens any of the existing drawings. To add a new just scroll to a new drawing record.
 

Attachments

Yeah that demo is helpful thank you very much, i have managed to get this to work.. i'm chuffed!

On another note would anyone know if there is the ability to use Access to create scalable SVG's? A few years ago we used Filemaker to create scaled drawings by controlling code through a WEB Viewer. The result is that you create a field (in my example its of a square window) field one say Width and field 2 being height and it would change the Code through the Web Viewer and give you a scaled drawing... has anyone any experience of this?
 
Are you really going to argue about this? How is the second drawing going to get its PK? are you going to force the user to close the popup so he can open it again for a second drawing
Sorry. I was not arguing with anyone. I was pointing out to the OP that you really never need to pass a value in with OpenArgs unless you use ACDIALOG as an argument of the Docmd, since that stops code execution in the calling form. If not calling it ACDIALOG you can simply set any property after opening the called form. This way you do not have to add additional code in the called form and tightly couple the called form to the calling form. Adding code in the before insert event tightly couples the drawing form to the job info form. At a minimum you need to validate if OpenArgs.
That is what I said and that is the point. Unless you have some reason for allowing the user to interact with multiple open forms, all it does is confuse the process. Open the popup. Do what has to be done. Close the popup. Clean. No confusion. No lost, buried forms.
I was explaining to the OP what Modal means since you stated it incorrectly.
That stops code execution in the calling form and keeps focus on the popup until it closes.
In Access that is incorrect. Modal does not stop code execution in the calling form. In other applications it does. In access only by calling the form passing the ACDIALOG of the Windowmode argument does. To prove that you can look at the demo I posted. I set the properties from the calling form after opening it Pop up and Modal.
I see you didn't implement what you suggested:) :) :) You might have mentioned that to @SwmpDnky because he probably didn't notice
Not sure what you are talking about here since I implemented it how I suggested, but I explained to the OP would have to do more depending on how they would like this to operate. Do they only want to allow the user to add a single drawing or go to the drawings?
You can combine it where it will open to any existing drawings, but will default to the JobID for subsequent.
I hope I at least opened your eyes to the error of your ways and you will now use a different method to populate the FK on a popup form:) You're welcome.
Not sure what error you speak of, I do not see any errors. There may be something in my explanation that you misinterpreted or did not understand.
 

Users who are viewing this thread

Back
Top Bottom